python - pd.Series.dt.weekday 与 pd.Series.dt.dayofweek 之间有区别吗?
问题描述
我在 Pandas 中度过了一段时间,并且已经看到有两种方法可以从时间戳中提取星期几整数。这些是pd.Series.dt.weekday
和pd.Series.dt.dayofweek
。
文档说两者都返回:Series 或 Index 包含整数,表示Monday=0
星期几与,所在的星期几Sunday=6
。
我是否遗漏了什么或者这两个功能实际上是相同的?
在“另请参阅”部分中,它确实将其他功能描述为别名。这能回答我的问题吗?
解决方案
你解决了你的问题:
| dayofweek
| The day of the week with Monday=0, Sunday=6.
|
| Return the day of the week. It is assumed the week starts on
| Monday, which is denoted by 0 and ends on Sunday which is denoted
| by 6. This method is available on both Series with datetime
| values (using the `dt` accessor) or DatetimeIndex.
|
| Returns
| -------
| Series or Index
| Containing integers indicating the day number.
|
| See Also
| --------
| Series.dt.dayofweek : Alias.
| Series.dt.weekday : Alias. # <-- YES IT'S AN ALIAS
| Series.dt.day_name : Returns the name of the day of the week.
源代码:
dayofweek = day_of_week
weekday = dayofweek
推荐阅读
- sql - 查询以计算所有雪花视图中的所有行
- audio - 如何让 FFmpeg 在单循环静音视频中自动注入 mp3 音轨?
- typescript - Typescript:仅在使用 Docker 时出现编译错误
- video-streaming - gstreamer 管道中的 rtpjitterbuffer
- vb.net - 为什么我的 VB.NET WebRequest 会突然停止工作?
- git - JGit 允许 Push 更新签出的分支
- python - 如何使用 Python3.7 中的 python 编译代码运行应用程序?
- python - python排序文件列表
- excel - 有没有办法解决excel中的下拉问题?
- python - Why we add templates path in DIRS in django?