问题遇到的现象和发生背景
做题过程中发现的问题
问题相关代码,请勿粘贴截图
对于一个表格表示总值,并输出最后一行
def task2():
import warnings
df=pd.read_csv(r'C:\Users\win10\Desktop\nftd\soi_dropnan.txt')
df.loc['列汇总']=df.sum()
print(df.tail(1))
运行结果及报错内容
task2()
Warning (from warnings module):
File "C:\Users\win10\Desktop\nftd\1.py", line 17
df.loc['列汇总']=df.sum()
FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
Date soi
列汇总 NaN -102.54
我的解答思路和尝试过的方法
在网络上寻找了很久,试了一些的屏蔽报错的方法,不过没有结果
我想要达到的结果
看不见报错即可