作者hiddenwind (我可以重来吗)
看板Python
标题[问题] pandas 表格内资料串连
时间Tue Sep 26 15:40:27 2017
请教板上各位先进,
因为抓取政府的公开资料,
可是日期格式为106.09.01
我想将日期作为index,
便将资料拆解为下表,
我看了join等接合方法,
但没找到相符的语法
请问要如何才能将资料重新结合为
2016.09.01呢?
感谢解惑
年 月 日
0 2016 09 01
.
.
.
29 2016 09 30
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 42.73.230.49
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1506411644.A.ACA.html
1F:→ painkiller: df['年'].astype(str)+'.'+df['月'].astype(str) 09/26 21:17
2F:推 steveyeh987: df[['年','月','日′]].apply(lambda x : '{}.{}.{}' 09/27 01:46
3F:→ steveyeh987: .format(x[0],x[1],x[2]), axis=1) 09/27 01:46
4F:推 f496328mm: py也有apply?不知道跟R的像不像 09/28 02:03
5F:推 Sunal: 这是pandas的apply 09/28 10:43
6F:→ hiddenwind: 可以了,感谢大大 09/29 09:52