使用dropna()函数去掉NaN的行或列 import pandas as pd import pickle import numpy as np dates = pd.date_range() df = pd.DataFrame(np.arange().reshape((,)), index=dates, columns=['A', 'B', 'C', 'D']) df.iloc[,]=np.nan df.iloc[,]=np.nan print(df) print(df.dropna(ax