【问题标题】:I have a pandas dataframe with weeks and days in each week. How do I consider the rows where the date matches with the day?我有一个熊猫数据框,每周有几周和几天。如何考虑日期与日期匹配的行?
【发布时间】:2017-06-14 17:41:32
【问题描述】:
2016-07-04  2016-06-24   154.0   320.0   923.0  1243.0  100.0   330.0  
2016-07-04  2016-06-27   195.0   384.0  1051.0  1501.0  117.0   413.0  
2016-07-04  2016-06-28   214.0   404.0  1066.0  1590.0  127.0   443.0 
2016-07-04  2016-06-29   232.0   420.0  1089.0  1677.0  139.0   466.0    
2016-07-04  2016-06-30   250.0   438.0  1099.0  1722.0  142.0   476.0  
2016-07-04  2016-07-01   264.0   443.0  1100.0  1725.0  143.0   476.0   
2016-07-04  2016-07-03   293.0   442.0  1091.0  1717.0  142.0   476.0  
2016-07-04  2016-07-04   406.0   442.0  1092.0  1718.0  142.0   476.0     

我只想考虑日期匹配的最后一行。数据大约是2年。 谢谢。

【问题讨论】:

    标签: python date pandas dataframe


    【解决方案1】:

    IIUC:

    df[df.iloc[:, 0] == df.iloc[:, 1]]
    
               0          1      2      3       4       5      6      7
    7 2016-07-04 2016-07-04  406.0  442.0  1092.0  1718.0  142.0  476.0
    

    【讨论】:

    • @KeshavMalpani 我写的内容已经应用于整个数据帧。考虑编辑您的问题并添加更多数据,以便我们更好地辨别相关条件。
    猜你喜欢
    • 2021-11-01
    • 2019-02-27
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 1970-01-01
    • 2011-04-06
    • 1970-01-01
    • 2022-12-19
    相关资源
    最近更新 更多