[问题] pandas爬虫问题

楼主: unknown (ya)   2018-08-02 03:48:31
df = pd.read_html('****')
a =pd.Dateframe(df[2]) #(要第二张表格,年月日资料)
b=pd.Dateframe(df[3]) #(第三张表格,资料内容)
请问要将a设定为b的columns要怎么用呢?
自己用
b =df[3],columns=a.iloc[0]
跑的出合并后的模式但缺只显示标头,b内容完全跑掉n/a,显示两个0列出来。
https://i.imgur.com/oZj2N1K.png
作者: TuCH (谬客)   2018-08-02 08:39:00
看不懂 有没有资料的范例 贴个前五笔资料出来看看
作者: TitanEric (泰坦)   2018-08-02 09:41:00
同楼上 是要改column name吗
作者: wii8898333 (frf228898)   2018-08-02 10:15:00
附上图片,在请各位赐教,谢
作者: TuCH (谬客)   2018-08-02 11:27:00
a 只有六栏 b有13栏?
作者: wii8898333 (frf228898)   2018-08-02 11:37:00
b前六栏有资料,后面是空的
作者: TuCH (谬客)   2018-08-02 11:44:00
b = b[:6], b.columns=a.iloc[0]b = b.iloc[:,:6], b.columns=a.iloc[0]

Links booklink

Contact Us: admin [ a t ] ucptt.com