计算日期在熊猫时间序列列表中出现的次数

时间:2019-01-24 21:14:21

标签: python pandas time-series

给出日期列表:

a = ['2013-12-14', '2013-12-14', '2013-12-24', '2013-12-25', '2013-12-25', '2013-12-25']

我想通过计算每个日期的出现来计算熊猫时间序列:

2013-12-14 2
2013-12-15 0
2013-12-16 0
...
2013-12-24 1
2013-12-25 3

我该怎么做?

1 个答案:

答案 0 :(得分:1)

您可以将to_datetime转换为datetime64,然后使用value_counts并重新采样:

/home/fabian/src/code-editor/app/Check.hs:11:1: error:
    • Illegal polymorphic type: Lens' (String, String) a2
      GHC doesn't yet support impredicative polymorphism
    • In the type signature:
        myField :: forall a_a5c6 a_a8tU.
                   Lens.Micro.Type.Lens (MyRecord a_a5c6) (MyRecord a_a8tU) (Lens' (String,
                                                                                    String) a_a5c6) (Lens' (String,
                                                                                                            String) a_a8tU)
   |
11 | makeLenses ''MyRecord