目录
1201、pandas.tseries.offsets.SemiMonthEnd.name属性
1202、pandas.tseries.offsets.SemiMonthEnd.rule_code属性
1203、pandas.tseries.offsets.SemiMonthEnd.n属性
1204、pandas.tseries.offsets.SemiMonthEnd.day_of_month属性
1205、pandas.tseries.offsets.SemiMonthEnd.copy方法



一、用法精讲
1201、pandas.tseries.offsets.SemiMonthEnd.name属性
1201-1、语法
# 1201、pandas.tseries.offsets.SemiMonthEnd.name属性
pandas.tseries.offsets.SemiMonthEnd.name
Return a string representing the base frequency.
1201-2、参数
无
1201-3、功能
提供关于该偏移量的简明描述,在调试或生成文档时非常有用,帮助用户了解他们正在使用的偏移类型。
1201-4、返回值
返回一个字符串'SME-15',表示该偏移量的名称。
1201-5、说明
无
1201-6、用法
1201-6-1、数据准备
无
1201-6-2、代码示例
# 1201、pandas.tseries.offsets.SemiMonthEnd.name属性
import pandas as pd
# 创建SemiMonthEnd偏移对象
semi_month_end_offset = pd.tseries.offsets.SemiMonthEnd()
# 访问name属性
offset_name = semi_month_end_offset.name
print(offset_name)
1201-6-3、结果输出
# 1201、pandas.tseries.offsets.SemiMonthEnd.name属性
# SME-15
1202、pandas.tseries.offsets.SemiMonthEnd.rule_code属性
1202-1、语法
# 1202、pandas.tseries.offsets.SemiMonthEnd.rule_code属性
pandas.tseries.offsets.SemiMonthEnd.rule_code
1202-2、参数
无
1202-3、功能
用于获取该偏移的规则代码。
1202-4、返回值
返回一个字符串,表示此偏移的类型,通常用于在时间序列操作中更方便地识别不同的时间偏移类型。
1202-5、说明
无
1202-6、用法
1202-6-1、数据准备
无
1202-6-2、代码示例
# 1202、pandas.tseries.offsets.SemiMonthEnd.rule_code属性
import pandas as pd
# 创建SemiMonthEnd偏移对象
semi_month_end_offset = pd.tseries.offsets.SemiMonthEnd()
# 获取规则代码
rule_code = semi_month_end_offset.rule_code
print(rule_code)
1202-6-3、结果输出
# 1202、pandas.tseries.offsets.SemiMonthEnd.rule_code属性
# SME-15
1203、pandas.tseries.offsets.SemiMonthEnd.n属性
1203-1、语法
# 1203、pandas.tseries.offsets.SemiMonthEnd.n属性
pandas.tseries.offsets.SemiMonthEnd.n
1203-2、参数
无
1203-3、功能
用于指定或获取时间偏移对象所包含的偏移量的数目。
1203-4、返回值
返回一个整数,表示这个偏移量的数量。
1203-5、说明
无
1203-6、用法
1203-6-1、数据准备
无
1203-6-2、代码示例
# 1203、pandas.tseries.offsets.SemiMonthEnd.n属性
import pandas as pd
# 创建SemiMonthEnd偏移对象,假设n=1
semi_month_end_offset = pd.tseries.offsets.SemiMonthEnd(n=1)
# 获取偏移数量
offset_n = semi_month_end_offset.n
print(offset_n)
1203-6-3、结果输出
# 1203、pandas.tseries.offsets.SemiMonthEnd.n属性
# 1
1204、pandas.tseries.offsets.SemiMonthEnd.day_of_month属性
1204-1、语法
# 1204、pandas.tseries.offsets.SemiMonthEnd.day_of_month属性
pandas.tseries.offsets.SemiMonthEnd.day_of_month
1204-2、参数
无
1204-3、功能
返回SemiMonthEnd偏移所指向的天数。在半月末的情况下,它通常会返回一个固定的值,表示这个偏移量所代表的日期。例如,对于一个月份的半末,可能返回15或30。
1204-4、返回值
返回的整数字段表示实际的日期部分,例如 15表示一个月的第15天,30表示一个月的第30天等。
1204-5、说明
无
1204-6、用法
1204-6-1、数据准备
无
1204-6-2、代码示例
# 1204、pandas.tseries.offsets.SemiMonthEnd.day_of_month属性
import pandas as pd
# 创建SemiMonthEnd偏移对象
semi_month_end_offset = pd.tseries.offsets.SemiMonthEnd()
# 获取day_of_month
day_of_month_value = semi_month_end_offset.day_of_month
print(day_of_month_value)
1204-6-3、结果输出
# 1204、pandas.tseries.offsets.SemiMonthEnd.day_of_month属性
# 15
1205、pandas.tseries.offsets.SemiMonthEnd.copy方法
1205-1、语法
# 1205、pandas.tseries.offsets.SemiMonthEnd.copy方法
pandas.tseries.offsets.SemiMonthEnd.copy()
Return a copy of the frequency.
1205-2、参数
无
1205-3、功能
用于创建当前SemiMonthEnd偏移对象的一个副本,该副本将具有与原始对象相同的属性和状态。
1205-4、返回值
返回一个新的SemiMonthEnd偏移对象,它是原对象的独立副本。
1205-5、说明
无
1205-6、用法
1205-6-1、数据准备
无
1205-6-2、代码示例
# 1205、pandas.tseries.offsets.SemiMonthEnd.copy方法
import pandas as pd
# 创建SemiMonthEnd偏移对象
semi_month_end_offset = pd.tseries.offsets.SemiMonthEnd()
# 复制该偏移对象
semi_month_end_offset_copy = semi_month_end_offset.copy()
# 验证是否为不同的对象
print(semi_month_end_offset is semi_month_end_offset_copy)
# 确认属性相同
print(semi_month_end_offset.day_of_month)
print(semi_month_end_offset_copy.day_of_month)
1205-6-3、结果输出
# 1205、pandas.tseries.offsets.SemiMonthEnd.copy方法
# False
# 15
# 15
4118

被折叠的 条评论
为什么被折叠?



