Python中文
首页
教程
问答
标签
搜索
登录
注册
以指定格式返回datetime
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我有以下代码:</p> <pre><code>import pandas as pd import locale locale.setlocale(locale.LC_ALL, 'nl_NL') from datetime import timedelta def get_maandnaam(maand): if maand == 1: return 'januari' if maand == 2: return 'februari' if maand == 3: return 'maart' if maand == 4: return 'april' if maand == 5: return 'mei' if maand == 6: return 'juni' if maand == 7: return 'juli' if maand == 8: return 'augustus' if maand == 9: return 'september' if maand == 10: return 'oktober' if maand == 11: return 'november' if maand == 12: return 'december' datum = pd.to_datetime("05" + " " + get_maandnaam(int(1)) + " " + "2000", format = "%d %B %Y") print(datum) </code></pre> <p>令我惊讶的是,在<code>print()</code>中,结果是<code>2000-01-05 00:00:00</code>。我期待着<code>5 januari 2000</code>。为什么会这样?这会被修复吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>您只需更改为:</p> <pre><code>datum = pd.to_datetime("05" + " " + get_maandnaam(1) + " " + "2000", format = "%d %B %Y").strftime('%d %B %Y') </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何合并多个PDF文件?
3 回答
如何合并多个xarray数据变量及其坐标?
1 回答
如何合并多个列中具有重复值的行
6 回答
如何合并多个唯一id
9 回答
如何合并多个图纸并使用图纸名称的名称重命名列名?
2 回答
如何合并多个字典并添加同一个键的值?(Python)
2 回答
如何合并多个搜索结果文件(pkl)以将它们全部打印在一起?
8 回答
如何合并多个数据帧
4 回答
如何合并多个数据帧并使用Pandas为假人添加列?
7 回答
如何合并多个数据帧并按时间戳排序
5 回答
如何合并多个数据帧的列表并用另一个lis标记每列
8 回答
如何合并多个数据框中的列
7 回答
如何合并多个文件?
2 回答
如何合并多个查询集?
5 回答
如何合并多个绘图?
7 回答
如何合并多个词典
8 回答
如何合并多个输入数据集(数据帧)?
10 回答
如何合并多条记录中拆分的文本行
6 回答
如何合并多索引列datafram
2 回答
如何合并多级(即多索引)数据帧?
2 回答