Python Data Frame resample on micro second

前端 未结 2 607
广开言路
广开言路 2021-02-03 15:57

I am working with resampling data frame and it works on hours, days mins, but doesn\'t resample less then sec. Program just hangs even on short time span. So am I missing someth

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 16:40

    If I understand your problem correctly you can't resample microseconds to another frequency that is less than a second, right? I made a toy example and there doesn't seem to be a problem though:

    import pandas as pd
    import numpy as np
    
    np.random.seed(0)
    index=pd.date_range('22/10/2010', periods=100000, freq='U')
    example=pd.Series(index=index,data=np.random.randn(100000))
    example.resample('ms',how='sum')
    

    This gives the expected output.

    (I think your problem is that you are trying to resample data that are in a microsecond format to microseconds itself, which doesn't make any sense. You want to either upsample or downsample (as in my example).)

提交回复
热议问题