Python 熊猫重新采样文档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17001389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:11:49  来源:igfitidea点击:

pandas resample documentation

pythondocumentationpandas

提问by Ryan Saxe

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

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

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

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

  • rule : the offset string or object representing target conversion
  • how : string, method for down- or re-sampling, default to ‘mean'
  • rule : 表示目标转换的偏移字符串或对象
  • how :字符串,向下或重新采样的方法,默认为“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.

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

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.

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

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?

那么文档中是否有我遗漏的显示pandas.resample's 规则的每个选项以及如何输入的地方?如果是,在哪里,因为我找不到它。如果不是,他们的所有选择是什么?

采纳答案by Matti John

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 howoptions, because it can be any NumPy array function and any function that is available via groupby dispatchingcan be passed to howby name.

请注意,这里没有列出所有不同how选项,因为它可以是任何 NumPy 数组函数,并且可以通过名称传递通过groupby 调度可用的任何函数how

回答by vonkohorn

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

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