找到 10786 篇文章 关于 Python

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

AmitDiwan
更新于 2021年10月22日 08:00:14

101 次浏览

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

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

AmitDiwan
更新于 2021年10月22日 07:56:38

81 次浏览

要返回应用于给定 CustomBusinessHour 对象的规则代码,请在 Pandas 中使用 CustomBusinessHour.rule_code 属性。首先,导入所需的库 - import pandas as pd 在 Pandas 中设置时间戳对象 - timestamp = pd.Timestamp('2021-11-14 05:20:30') 创建 CustomBusinessHour 偏移量。CustomBusinessHour 是 DateOffset 子类 - cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 4, weekmask = 'Mon Tue Wed Fri Sat' ,normalize=True) 将偏移量添加到时间戳并显示更新后的时间戳 - print("Updated Timestamp...", timestamp + cbhOffset) 返回应用于给定 CustomBusinessHour 偏移量的频率的规则代码 - print("The rule code of the CustomBusinessHour object..", cbhOffset.rule_code) 示例 以下为代码 - import pandas as pd # ... 阅读更多

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

AmitDiwan
更新于 2021年10月22日 07:51:30

78 次浏览

要检查 CustomBusinessHour 偏移量是否已标准化,请在 Pandas 中使用 CustomBusinessHour.normalize 属性。首先,导入所需的库 - import pandas as pd 在 Pandas 中设置时间戳对象 - timestamp = pd.Timestamp('2021-10-25 08:35:10') 创建 CustomBusinessHour 偏移量。CustomBusinessHour 是 DateOffset 子类。我们使用“normalize”参数标准化了 CustomBusinessDay - cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 3, weekmask = 'Mon Tue Wed Fri Sat' ,normalize=True) 将偏移量添加到时间戳并显示更新后的时间戳 - print("Updated Timestamp...", timestamp + cbhOffset) 检查 CustomBusinessHour 偏移量是否已标准化 - print("The CustomBusinessHour Offset is normalized ?", cbhOffset.normalize) 示例 以下为代码 ... 阅读更多

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

AmitDiwan
更新于 2021年10月22日 07:49:50

65 次浏览

要返回应用于给定 CustomBusinessHour 偏移量对象的频率名称,请在 Pandas 中使用 CustomBusinessHour.name 属性。首先,导入所需的库 - import pandas as pd 在 Pandas 中设置时间戳对象 - timestamp = pd.Timestamp('2021-10-25 08:35:10') 创建 CustomBusinessHour 偏移量。CustomBusinessHour 是 DateOffset 子类 - cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 3, weekmask = 'Mon Tue Wed Fri Sat') 将偏移量添加到时间戳并显示更新后的时间戳 - print("Updated Timestamp...", timestamp + cbhOffset) 返回应用于给定 CustomBusinessHour 对象的频率名称 - print("The name of the frequency on the CustomBusinessHour object..", cbhOffset.name) 示例 以下为代码 - import ... 阅读更多

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

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

91 次浏览

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

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

AmitDiwan
更新于 2021年10月22日 07:43:35

56 次浏览

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

Python Pandas CustomBusinessHour - 将提供的日期向后回滚

AmitDiwan
更新于 2021年10月22日 07:41:38

80 次浏览

要将提供的日期向后回滚,请在 Pandas 中使用 CustomBusinessHour.rollback() 方法。首先,导入所需的库 - import pandas as pd 在 Pandas 中设置时间戳对象 - timestamp = pd.Timestamp('2021-12-20 08:35:10') 创建 CustomBusinessHour 偏移量。CustomBusinessHour 是 DateOffset 子类 - cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 5, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到时间戳并显示更新后的时间戳 - print("Updated Timestamp...", timestamp + cbhOffset) 如果不在偏移量上,则向后回滚 - roll_back = cbhOffset.rollback(pd.Timestamp('2021-12-18 08:35:10')) 显示结果 - print("Roll Backward Result...", roll_back) 示例 以下为代码 - import pandas as pd # 在 Pandas 中设置时间戳对象 timestamp = pd.Timestamp('2021-12-20 ... 阅读更多

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

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

72 次浏览

要移动到下一个工作日,请在 Pandas 中使用 CustomBusinessHour.next_bday 属性。首先,导入所需的库 - import pandas as pd 在 Pandas 中设置时间戳对象 - timestamp = pd.Timestamp('2021-12-20 08:35:10') 创建 CustomBusinessHour 偏移量。CustomBusinessHour 是 DateOffset 子类 - cbhOffset = pd.tseries.offsets.CustomBusinessHour(start ='09:30', end ='18:00', n = 5, weekmask = 'Mon Tue Wed Fri') 显示 CustomBusinessHour 偏移量 - print("CustomBusinessHour Offset...", cbhOffset) 显示下一个工作日 - print("The next business day...", timestamp + cbhOffset.next_bday) 示例 以下为代码 - import pandas as pd # 在 Pandas 中设置时间戳对象 timestamp = pd.Timestamp('2021-12-20 08:35:10') # 显示时间戳 print("Timestamp...", timestamp) ... 阅读更多

Python Pandas CustomBusinessHour - 将提供的日期向前滚动到下一个偏移量(仅当不在偏移量上时)

AmitDiwan
更新于 2021年10月22日 07:38:41

153 次浏览

要将提供的日期向前滚动到下一个偏移量(仅当不在偏移量上时),请在 Pandas 中使用 CustomBusinessHour.rollforward() 方法。首先,导入所需的库 - import pandas as pd 在 Pandas 中设置时间戳对象 - timestamp = pd.Timestamp('2021-12-20 08:35:10') 创建 CustomBusinessHour 偏移量。CustomBusinessHour 是 DateOffset 子类。有效工作日的星期掩码 - cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 5, weekmask = 'Mon Tue Wed Fri') 将偏移量添加到时间戳并显示更新后的时间戳 - print("Updated Timestamp...", timestamp + cbhOffset) 如果不在偏移量上,则向前滚动 - roll = cbhOffset.rollforward(pd.Timestamp('2021-12-30 08:35:10')) 显示结果 - print("Roll forward Result...", roll) 示例 以下为代码 - import pandas as ... 阅读更多

Python Pandas - 创建自定义工作日偏移量对象

AmitDiwan
更新于 2021-10-22 07:36:35

浏览量 119

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

广告

© . All rights reserved.