Python中的 pandas.bdate_range()函数
该方法用于返回固定频率的 DatetimeIndex,默认频率为工作日。
Syntax : pandas.bdate_range(start=None, end=None, periods=None, freq=’B’, tz=None, normalize=True, name=None, weekmask=None, holidays=None, closed=None, **kwargs,)
Parameters :
- start : string or datetime-like, default None, Left bound for generating dates.
- end : string or datetime-like, default None, Right bound for generating dates.
- periods : integer, default None, Number of periods to generate.
- freq : string or DateOffset, default ‘B’ (business daily), Frequency strings can have multiples, e.g. ‘5H’.
- tz : string or None, Time zone name for returning localized DatetimeIndex, for example Asia/Beijing.
以下是上述方法的实现以及一些示例:
示例 1:
Python3
# importing packages
import pandas
# using pandas.bdate_range() method
print(pandas.bdate_range(start='8/1/2020',
end='8/20/2020'))
Python3
# importing packages
import pandas
# using pandas.bdate_range() method
print(pandas.bdate_range(start='8/1/2020',
end='8/5/2020',
freq='5H'))
输出:
示例 2:
Python3
# importing packages
import pandas
# using pandas.bdate_range() method
print(pandas.bdate_range(start='8/1/2020',
end='8/5/2020',
freq='5H'))
输出 :