我怎样才能让 pandas 显示我的其余行信息?(不想在数据框中看到 NaN)
how can i make pandas to show the rest of my rows info?(don't want to see NaN in data frame)
我正在尝试过滤掉 test.csv table 中仅包含数字 2 和 33 的行。
如何检索 NaN 值?
import pandas as pd
df = pd.read_csv('test.csv')
display(df.head(15))
x = df[(df == 2) | (df == 33)]
display(x)
您可以在此处查看 jupyter notebook PNG 文件。
我认为这不是最好的方法,但它可以做到:
x = df[df.apply(lambda row: 2 in list(row) or 22 in list(row), axis=1)]
df[df.isin([2,33]).any(axis = 1)]
这将显示其中包含 2 或 33 的任何行。
我正在尝试过滤掉 test.csv table 中仅包含数字 2 和 33 的行。 如何检索 NaN 值?
import pandas as pd
df = pd.read_csv('test.csv')
display(df.head(15))
x = df[(df == 2) | (df == 33)]
display(x)
您可以在此处查看 jupyter notebook PNG 文件。
我认为这不是最好的方法,但它可以做到:
x = df[df.apply(lambda row: 2 in list(row) or 22 in list(row), axis=1)]
df[df.isin([2,33]).any(axis = 1)]
这将显示其中包含 2 或 33 的任何行。