gpt4 book ai didi

python - 根据一天中的时间选择 DataFrame 中的行?

转载 作者:太空宇宙 更新时间:2023-11-04 09:25:21 24 4
gpt4 key购买 nike

我有一个以 Datetime 作为我的 index_col 的 DataFrame。此数据为 14 天。我想根据一天中的时间创建两个不同的 DataFrame:每天早上 6 点到下午 18 点之间的数据作为一个 df,而每天下午 18 点到早上 6 点之间的数据在另一个 df 中。如何提取?

下面是我的Dataframe截图

enter image description here

最佳答案

尝试使用

对于 df1

df1=df.between_time('06:00', '18:00')

对于 df2

df2=df.between_time('18:00', '06:00')

更多信息 here

关于python - 根据一天中的时间选择 DataFrame 中的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57935290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com