本文主要是介绍如何通过pandas.apply进行整列和整行计算,以及如何处理A value is trying to be set on a copy of a slice from a DataFrame.错误,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
df[['星期日']].apply(lambda x:time_diff(x),axis = 0) #axis = 0 将每列数据传入,axis = 1将每行数据传入
#df[['星期日']].apply(time_diff,axis = 0) #axis = 0 将每列数据传入,axis = 1将每行数据传入
#df.apply(time_diff,axis = 1) #axis = 0 将每列数据传入,axis = 1将每行数据传入
'''
将内容增加到副本上面去前,需要将副本拷贝一下,否则会弹出A value is trying to be set on a copy of a slice from a DataFrame.
'''
df2 = df[['星期一']]
print(df2)
df3 = df2.copy()
df3['时间差'] = pd.Series(data=time_diff_list,index=df3.index)
这篇关于如何通过pandas.apply进行整列和整行计算,以及如何处理A value is trying to be set on a copy of a slice from a DataFrame.错误的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!