像数据熊猫一样处理独立数据帧

时间:2018-11-21 22:37:52

标签: python python-3.x pandas

我正在将几个数据帧连接成一个:

frames= [df3,df5,df4,df6,df7,df8,df9,df10]
df11=pd.concat(frames,axis=1)
df12= pd.DataFrame (df11)
#year = ['2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015','2016','2017']
#df12['year']= year
#df12.year = pd.to_datetime(df12.year)
#df12.index = df12.year
#df12=df12.sort_index
df12.info()
df12.head()

然后看起来像:

    rel_uncertain   rel_modal_wk    rel_positive    rel_modal_me    rel_modal_st    rel_cnstrain    rel_litigious   rel_negative
0   0.003264    0.000568    0.007659    0.002442    0.011443    0.002170    0.004246    0.003857
1   0.006195    0.002193    0.007991    0.002325    0.009876    0.002229    0.007343    0.006189
2   0.005952    0.000719    0.011846    0.001773    0.009697    0.001392    0.001874    0.003313
3   0.006306    0.001038    0.008452    0.001925    0.009386    0.001180    0.002856    0.001219
4   0.005013    0.001374    0.007348    0.001017    0.008259    0.001533    0.003306    0.004437

下一步,我想设置一个日期时间索引,但是当我删除代码中的#时,出现以下错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-35-e917aaa1e676> in <module>()
      7 df12.index = df12.year
      8 df12=df12.sort_index
----> 9 df12.info()
     10 df12.head()

AttributeError: 'function' object has no attribute 'info'

0 个答案:

没有答案