首页 文章

pandas resample文档[关闭]

提问于
浏览
141

所以我完全理解如何使用resample,但文档并没有很好地解释选项 .

所以 resample 函数中的大多数选项都很简单,除了这两个:

  • rule:表示目标转换的偏移字符串或对象

  • how:string,down-or-sampling的方法,默认为'mean'

因此,通过查看我在网上找到的尽可能多的示例,我可以看到规则你可以做 'D' 一天, 'xMin' 做分钟, 'xL' 做毫秒,但这就是我能找到的 .

我是如何看到以下内容的: 'first'np.max'last''mean''n1n2n3n4...nx' 其中nx是每个列索引的第一个字母 .

那么在我缺少的文档中是否存在显示 pandas.resample 规则的每个选项以及如何输入?如果是的话,因为我找不到它 . 如果没有, what are all the options for them?

2 回答

  • 64
    B       business day frequency
    C       custom business day frequency (experimental)
    D       calendar day frequency
    W       weekly frequency
    M       month end frequency
    SM      semi-month end frequency (15th and end of month)
    BM      business month end frequency
    CBM     custom business month end frequency
    MS      month start frequency
    SMS     semi-month start frequency (1st and 15th)
    BMS     business month start frequency
    CBMS    custom business month start frequency
    Q       quarter end frequency
    BQ      business quarter endfrequency
    QS      quarter start frequency
    BQS     business quarter start frequency
    A       year end frequency
    BA      business year end frequency
    AS      year start frequency
    BAS     business year start frequency
    BH      business hour frequency
    H       hourly frequency
    T       minutely frequency
    S       secondly frequency
    L       milliseonds
    U       microseconds
    N       nanoseconds
    

    timeseries documentation . 它包含offsets(和'anchored' offsets)的列表,以及关于resampling的部分 .

    请注意,没有所有不同 how 选项的列表,因为它可以是任何NumPy数组函数,并且通过groupby dispatching可用的任何函数都可以按名称传递给 how .

  • 239

    除此之外还有更多内容,但您可能正在寻找此列表:

    B   business day frequency
    C   custom business day frequency (experimental)
    D   calendar day frequency
    W   weekly frequency
    M   month end frequency
    BM  business month end frequency
    MS  month start frequency
    BMS business month start frequency
    Q   quarter end frequency
    BQ  business quarter endfrequency
    QS  quarter start frequency
    BQS business quarter start frequency
    A   year end frequency
    BA  business year end frequency
    AS  year start frequency
    BAS business year start frequency
    H   hourly frequency
    T   minutely frequency
    S   secondly frequency
    L   milliseconds
    U   microseconds
    

    资料来源:http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases

相关问题