找到关于 Python 的10786 篇文章

Python Pandas - 获取应用于 CustomBusinessDay 偏移量的 weekmask

AmitDiwan
更新于 2021年10月22日 07:34:14

160 次浏览

要获取应用于 CustomBusinessDay 偏移量的 weekmask,请在 Pandas 中使用 CustomBusinessDay.weekmask 属性。首先,导入所需的库 −import pandas as pd 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-10-22 03:10:35') 创建 CustomBusinessDay 偏移量。CustomBusinessDay 是表示自定义工作日(不包括节假日)的 DateOffset 子类。有效工作日的 Weekmask −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 4, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 显示 weekmask −print("The weekmask on the CustomBusinessDay object..", cbdOffset.weekmask) 示例以下是代码 −import pandas as pd # 设置 ... 阅读更多

Python Pandas - 返回应用于 CustomBusinessDay 偏移量的增量计数

AmitDiwan
更新于 2021年10月22日 07:31:25

74 次浏览

要返回应用于 CustomBusinessDay 偏移量的增量计数,请在 Pandas 中使用 CustomBusinessDay.n 属性。首先,导入所需的库 −import pandas as pd 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-10-22 03:10:35') 创建 CustomBusinessDay 偏移量 −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 4, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 返回给定 CustomBusinessDay 对象上的增量计数 −print("The count of increments on the CustomBusinessDay object..", cbdOffset.n) 示例以下是代码 −import pandas as pd # 设置时间戳对象在 Pandas 中的时间戳 ... 阅读更多

Python Pandas - 返回应用于给定 CustomBusinessDay 对象的规则代码

AmitDiwan
更新于 2021年10月22日 07:21:28

53 次浏览

要返回应用于给定 CustomBusinessDay 对象的规则代码,请在 Pandas 中使用 CustomBusinessDay.rule_code 属性。首先,导入所需的库 −import pandas as pd 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-10-22 03:10:35') 创建 CustomBusinessDay 偏移量。CustomBusinessDay 是表示自定义工作日(不包括节假日)的 DateOffset 子类 −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 返回应用于给定 CustomBusinessDay 偏移量的频率的规则代码 −print("The rule code of the CustomBusinessDay object..", cbdOffset.rule_code) 示例以下是代码 ... 阅读更多

Python Pandas - 检查 CustomBusinessDay 偏移量是否已标准化

AmitDiwan
更新于 2021年10月22日 07:08:04

109 次浏览

要检查 CustomBusinessDay 偏移量是否已标准化,请在 Pandas 中使用 CustomBusinessDay.normalize 属性。首先,导入所需的库 −import pandas as pd 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-10-22 03:10:35') 创建 CustomBusinessDay 偏移量。CustomBusinessDay 是表示自定义工作日(不包括节假日)的 DateOffset 子类。有效工作日的 Weekmask。我们使用“normalize”参数对 CustomBusinessDay 进行了标准化 −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri', normalize=True) 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 检查 CustomBusinessDay 偏移量是否已标准化 ... 阅读更多

Python Pandas - 返回应用于给定 CustomBusinessDay 偏移量对象的频率名称

AmitDiwan
更新于 2021年10月22日 07:05:54

61 次浏览

要返回应用于给定 CustomBusinessDay 偏移量对象的频率名称,请使用 CustomBusinessDay.name 属性。首先,导入所需的库 −import pandas as pd 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-12-31 08:35:10') 创建 CustomBusinessDay 偏移量。CustomBusinessDay 是表示自定义工作日(不包括节假日)的 DateOffset 子类 −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 返回应用于给定 CustomBusinessDay 对象的频率名称 −print("The name of the frequency on the CustomBusinessDay object..", cbdOffset.name) 示例以下是 ... 阅读更多

Python Pandas - 显示应用于给定 CustomBusinessDay 对象的关键字参数

AmitDiwan
更新于 2021年10月22日 07:03:47

76 次浏览

要显示应用于给定 CustomBusinessDay 对象的关键字参数,请在 Pandas 中使用 CustomBusinessDay.kwds 属性。首先,导入所需的库 −import pandas as pd 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-12-31 08:35:10') 创建 CustomBusinessDay 偏移量 −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 显示关键字参数 −print("Keyword arguments on the given CustomBusinessDay Offset...", cbdOffset.kwds) 示例以下是代码 −import pandas as pd # 设置 Pandas 中的时间戳对象 timestamp = pd.Timestamp('2021-12-31 08:35:10') # 显示 ... 阅读更多

Python Pandas - 将应用于给定 CustomBusinessDay 偏移量对象的频率作为字符串返回

AmitDiwan
更新于 2021年10月22日 07:00:36

70 次浏览

要将应用于给定 CustomBusinessDay 偏移量对象的频率作为字符串返回,请使用 CustomBusinessDay.freqstr 属性。首先,导入所需的库 −import pandas as pd 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-12-31 08:35:10') 创建 CustomBusinessDay 偏移量 −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 将应用于给定 CustomBusinessDay 偏移量对象的频率作为字符串返回 −print("Frequency applied on the given CustomBusinessDay Offset object...", cbdOffset.freqstr) 示例以下是代码 −import pandas as pd # 设置 Pandas 中的时间戳对象 ... 阅读更多

Python Pandas - 创建 CustomBusinessDay 偏移量对象

AmitDiwan
更新于 2021年10月22日 06:55:52

382 次浏览

要创建 CustomBusinessDay 偏移量对象,请在 Pandas 中使用 pd.tseries.offsets.CustomBusinessDay() 方法。首先,导入所需的库 −import pandas as pd 创建 CustomBusinessDay 偏移量。CustomBusinessDay 是表示自定义工作日(不包括节假日)的 DateOffset 子类。有效工作日的 Weekmask −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 5, weekmask = 'Mon Tue Wed Fri') 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-12-31 08:35:10') 将偏移量添加到 Timestamp 并显示更新后的 Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) 示例以下是代码 −import pandas as pd # 设置 Pandas 中的时间戳对象 timestamp = pd.Timestamp('2021-12-31 08:35:10') # 显示 ... 阅读更多

Python Pandas BusinessHour 偏移量对象 - 移动到下一个工作日

AmitDiwan
更新于 2021年10月21日 08:59:04

239 次浏览

使用 Pandas 中的 BusinessHour.next_bday 属性移动到下一个工作日。首先,导入所需的库 −import datetime import pandas as pd 创建 BusinessHour 偏移量。BusinessHour 是 DateOffset 子类 −bhOffset = pd.tseries.offsets.BusinessHour(offset = datetime.timedelta(days = 3, hours = 3)) 显示 BusinessHour 偏移量 −print("BusinessHour Offset...", bhOffset) 设置 Pandas 中的时间戳对象 −timestamp = pd.Timestamp('2021-9-30 06:50:20') 显示下一个工作日 −print("The next business day...", timestamp + bhOffset.next_bday) 示例以下是代码 −import datetime import pandas as pd # 设置 Pandas 中的时间戳对象 timestamp = pd.Timestamp('2021-9-30 06:50:20') # 显示时间戳 print("Timestamp...", timestamp) # ... 阅读更多

Python Pandas - 从 BusinessHour 偏移量对象以 24 小时格式显示自定义工作小时的结束时间

AmitDiwan
更新于 2021年10月21日 08:57:22

80 次浏览

要从 BusinessHour 偏移量对象中以 24 小时格式显示自定义营业时间的结束时间,请使用 BusinessHour.end 属性。首先,导入所需的库 −import pandas as pd 在 Pandas 中设置时间戳对象 −timestamp = pd.Timestamp('2021-9-30 06:50:20') 创建 BusinessHour 偏移量。这里,“start” 是您自定义营业时间以 24 小时格式表示的开始时间。“end” 是您自定义营业时间以 24 小时格式表示的结束时间 −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00", n = 8) 显示更新后的时间戳 −print("Updated Timestamp...", timestamp + bhOffset) 显示自定义营业时间的结束时间 −print("The end ... 阅读更多

广告
© . All rights reserved.