我有一个需要过滤的数据帧,就像一个特定月份的sql查询一样。每次运行代码时,我都希望它从上个月获取数据,无论当前月份的具体日期是什么。你知道吗
我的SQL代码在这里,但我需要它。你知道吗
WHERE DATEPART(m, logged) = DATEPART(m, DATEADD(m, -1, getdate()))
df = pd.DataFrame({'month': ['1-05-01 00:00:00','1-06-01 00:00:00','1-06-01 00:00:00','1-05-01 00:00:00']})
df['month'] = pd.to_datetime(df['month'])```
In this example, I only want the data from June.
Would definitely appreciate the help! Thanks.
根据问题编辑修改:
输出:
相关问题 更多 >
编程相关推荐