以下示例是关于Python中包含重塑数据帧中的日期时间列值用法的示例代码,想了解重塑数据帧中的日期时间列值的具体用法?重塑数据帧中的日期时间列值怎么用?重塑数据帧中的日期时间列值使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。
Ej. 日期为 10 分钟。
import pandas as pd
def dt_reshape(df:pd.DataFrame, c_dt:str, dt_shape:str = "10MIN")->pd.DataFrame:
# validate arguments
assert c_dt in df.columns.tolist()
# to x minutal
df[c_dt] = df[c_dt].dt.floor(dt_shape).values
# return
return df
本文地址:https://www.itbaoku.cn/snippets/876619.html