您需要 登录 才可以下载或查看,没有账号?立即注册
import pandas as pd import numpy as np val = np.arange(10, 38).reshape(7, 4) col = list("abcd") idx = "cake make fake sake wake lake take".split() df = pd.DataFrame(val, columns = col, index = idx) df["e"] = np.nan df.at["make", "e"] = 100 df["f"] = np.nan df.loc["gake"] = np.nan print (df) df.dropna(axis = 1, thresh = 2,inplace=True) # 至少有两个非NaN的列留下 print('至少有两个非NaN的列留下',df)
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)
GMT+8, 2025-1-17 01:06
Powered by Discuz! X3.4
© 2001-2023 Discuz! Team.