猿问

如何格式化groupby year函数pandas - 返回unicode属性错误

使用下面的代码尝试按年份计算条目数,返回 unicode 值错误。下面的实现有替代方案吗?


raw_news_4.groupby(raw_news_4["date_publish"].map(lambda x: x.year))


#raw_news_4 sample


date_publish    title

213059  2006-10-18 12:47:13 Is God dead Atheism finds a market in     US

20559   2006-11-12 13:11:20 WITNESS Waking up paralyzed in Sri     Lankas war zone

111765  2007-01-18 23:02:00 AIDS in Americas

123806  2007-01-18 23:02:00 Malaria

7060    2007-01-18 23:02:00 AIDS pandemic

121746  2007-01-18 23:02:00 Indonesia mudflow

206142  2007-01-18 23:02:00 Pakistan violence

241749  2007-01-18 23:02:00 


AttributeError: 'unicode' object has no attribute 'year'


jeck猫
浏览 100回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答