Python Pandas Timestamp.ceil
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。
Pandas Timestamp.ceil()函数返回一个新的Timestamp,并以该分辨率计算。该函数将所需的时间序列频率作为输入。
语法 :
Timestamp.ceil()
参数 :
freq :一个freq字符串,表示最高分辨率。
返回:时间戳
例子#1:使用Timestamp.ceil()函数将给定的Timestamp对象ceil到Daily时间序列频率。
# importing pandas as pd
import pandas as pd
# Create the Timestamp object
ts = pd.Timestamp(year = 2011, month = 11, day = 21,
hour = 10, second = 49, tz = 'US/Central')
# Print the Timestamp object
print(ts)
输出 :
现在我们将使用Timestamp.ceil()函数将ts对象ceil到Daily频率。
# ceil the given object to daily frequency
ts.ceil(freq ='D')
输出 :
正如我们在输出中看到的,Timestamp.ceil()函数已经将给定的Timestamp对象的时间序列频率与输入频率进行了分割。
例子2:使用Timestamp.ceil()函数将给定的Timestamp对象ceil到分钟级的时间序列频率。
# importing pandas as pd
import pandas as pd
# Create the Timestamp object
ts = pd.Timestamp(year = 2009, month = 5, day = 31,
hour = 4, second = 49, tz = 'Europe/Berlin')
# Print the Timestamp object
print(ts)
输出 :
现在我们将使用Timestamp.ceil()函数将ts对象ceil到微小的频率。
# ceil the given object to minutely frequency
ts.ceil(freq ='T')
输出 :
正如我们在输出中看到的,Timestamp.ceil()函数已经将给定的Timestamp对象的时间序列频率与输入频率进行了分割。