![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pandas
空空道长
传统美德:
I have a dream:云游四方。
展开
-
pandas 多重列名 KeyError报错
df = pd.DataFrame({'col1':[np.NaN,2,3,4],'col2':[2,np.NaN,4,5],'col3':[3,4,5,6]})df.columns = [['col','col','col'],['col1','col2','col3']] df['xxx']['col'] = [22,2,22,2] ## 居然会报错KeyError: 'xxx'原因如下:https://pandas.pydata.org/pandas-docs/stab...原创 2020-06-04 15:20:11 · 1587 阅读 · 0 评论 -
pandas 私货
import numpy as npimport pandas as pddf = pd.DataFrame({'col1':[np.NaN,2,3,4],'col2':[2,np.NaN,4,5],'col3':[3,4,5,6]})df.columns = [['col','col','col'],['col1','col2','col3']] # 重置列名,多重列名''' col col1 col2 col30 1 2 31 2..原创 2020-06-03 16:29:00 · 172 阅读 · 1 评论