问题:熊猫重新采样文档

因此,我完全理解如何使用resample,但是文档在解释这些选项方面做得不好。

因此,resample除了以下两个以外,函数中的大多数选项都非常简单:

  • rule:表示目标转换的偏移量字符串或对象
  • 方式:字符串,下采样或重新采样的方法,默认为“均值”

因此,通过查看我在网上找到的尽可能多的示例,我可以看到规则可以'D'在一天,'xMin'几分钟,'xL'几毫秒内完成,但这就是我所能找到的全部。

如何我看到的情况如下:'first'np.max'last''mean',和'n1n2n3n4...nx'其中nx为每列索引的第一个字母。

因此,我在文档中缺少的某个地方显示了pandas.resample规则的每个选项以及如何输入?如果是,在哪里,因为我找不到它。如果没有,那么他们有什么选择?

So I completely understand how to use resample, but the documentation does not do a good job explaining the options.

So most options in the resample function are pretty straight forward except for these two:

  • rule : the offset string or object representing target conversion
  • how : string, method for down- or re-sampling, default to ‘mean’

So from looking at as many examples as I found online I can see for rule you can do 'D' for day, 'xMin' for minutes, 'xL' for milliseconds, but that is all I could find.

for how I have seen the following: 'first', np.max, 'last', 'mean', and 'n1n2n3n4...nx' where nx is the first letter of each column index.

So is there somewhere in the documentation that I am missing that displays every option for pandas.resample‘s rule and how inputs? If yes, where because I could not find it. If no, what are all the options for them?


回答 0

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, BY    business year end frequency
AS, YS    year start frequency
BAS, BYS  business year start frequency
BH        business hour frequency
H         hourly frequency
T, min    minutely frequency
S         secondly frequency
L, ms     milliseconds
U, us     microseconds
N         nanoseconds

请参阅时间序列文档。它包括偏移量列表(和“锚定”偏移量),以及有关重采样的部分。

请注意,没有所有不同how选项的列表,因为它可以是任何NumPy数组函数,并且可以通过nameby传递通过groupby分派可用的任何函数how

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, BY    business year end frequency
AS, YS    year start frequency
BAS, BYS  business year start frequency
BH        business hour frequency
H         hourly frequency
T, min    minutely frequency
S         secondly frequency
L, ms     milliseconds
U, us     microseconds
N         nanoseconds

See the timeseries documentation. It includes a list of offsets (and ‘anchored’ offsets), and a section about resampling.

Note that there isn’t a list of all the different how options, because it can be any NumPy array function and any function that is available via groupby dispatching can be passed to how by name.


回答 1

不仅限于此,但您可能正在寻找以下列表:

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

There’s more to it than this, but you’re probably looking for this list:

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

Source: http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。