pandas.date_range freq

pandas.date_range(start=None, end=None, periods=None, freq=None, tz=None, normalize=False, name=None, closed=None, **kwargs)
返回固定频率的DatetimeIndex。
这个函数的作用就是产生一个DatetimeIndex,就是时间序列数据的索引。

Parameters:
start: str or datetime-like, optional
Left bound for generating dates.

end: str or datetime-like, optional
Right bound for generating dates.

periods: int, optional
Number of periods to generate.

freq: str or DateOffset, default ‘D’
Frequency strings can have multiples, e.g. ‘5H’. See here for a list of frequency aliases.
freq参数枚举

tz: str or tzinfo, optional
Time zone name for returning localized DatetimeIndex, for example ‘Asia/Hong_Kong’. By default, the resulting DatetimeIndex is timezone-naive.

normalize: bool, default False
Normalize start/end dates to midnight before generating date range.

name: str, default None
Name of the resulting DatetimeIndex.

closed: {None, ‘left’, ‘right’}, optional
Make the interval closed with respect to the given frequency to the ‘left’, ‘right’, or both sides (None, the default).

**kwargs
For compatibility. Has no effect on the result.

Returns
**rng:**DatetimeIndex

Notes:
在start、end、period和freq这四个参数中,只有三个必须指定。如果省略freq,得到的DatetimeIndex将在开始和结束之间具有周期线性间隔的元素(两边都是闭合的)。

栗子:

plt.xticks(pd.date_range(readDataList[2][1][1][0],readDataList[2][24][1][0],freq = "Y"),fontsize = 15)

Reference:

https://blog.csdn.net/wangqi_qiangku/article/details/79384731
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.date_range.html

你可能感兴趣的:(数据分析,python,python)