Filtering and comparing dates with Pandas

后端 未结 3 1871
花落未央
花落未央 2021-02-09 04:51

I would like to know how to filter different dates at all the different time levels, i.e. find dates by year, month, day, hour, minute and/or day. For example, how do I find all

3条回答
  •  死守一世寂寞
    2021-02-09 05:31

    If you set timestamp as index and dtype as datetime to get a DateTimeIndex, then you can use the following Partial String Indexing syntax:

    df['2014'] # gets all 2014
    df['2014-01'] # gets all Jan 2014
    df['01-02-2014'] # gets all Jan 2, 2014
    

提交回复
热议问题