python - 仅将时间戳转换为月份名称
问题描述
我想将数据框列中的每个时间戳更改为月份名称。
date =[]
month=0
for j in clean_data['created_at']:
date.append(j)
month = time.strftime("%b",time.gmtime(date))
print(month)
我有以下错误:
TypeError:需要一个整数(获取类型 str)
我的预期输出是“一月,二月,三月等......”。例如,我 2019-06-13T14:22:28Z
只想成为Jun
解决方案
尝试:
clean_data['created_at']= pd.to_datetime(clean_data['created_at'])
clean_data['created_at'].dt.month_name().str[:3]
推荐阅读
- php - 在数据库插入之前检查记录是否存在
- html - 如果登录出现问题,如何强制我的登录页面返回原始页面?
- java - 带有额外列的 Spring REST 多对多
- javascript - 如何将 h1 直接放置在输入上并适用于所有屏幕?
- python - python3中`re.findall(r'(.)*', 'aabc')`结果的原因
- mysql - mysql查询结果获取同一id上的一条记录
- node.js - 如何在服务器上的 express 和 node 中创建文件,然后将其下载到我的客户端。我正在为我的前端和后端使用 NextJS
- python - 如何创建更具活力的 Scrapy Spider?
- javascript - 在循环中声明的 React js 函数包含对“允许”变量的不安全引用
- git - 有没有办法对存储库中的各个组件进行版本/标记?