【发布时间】:2021-09-02 00:43:37
【问题描述】:
我有一个包含大约 10 列的“some.xlsb”文件,其中 2 列是 DateTime 列。
当我使用 pandas 加载时,日期时间列会以不同的形式解析。
解释:
其中DateTime 值对应于4/10/2021 11:50:24 AM - 读作44296.5
下面是我试过的代码。
goods_df = pd.read_excel('some.xlsb',
engine='pyxlsb', sheet_name='goods_df')
goods_df_header = goods_df.iloc[1]
goods_df.columns = goods_df_header #set the header row as the df header
goods_df= goods_df[2:]
goods_df.head(2)
【问题讨论】:
-
您可能希望在导入后对日期时间进行解析,请参见例如Convert Excel style date with pandas.
标签: python-3.x pandas dataframe datetime pyxlsb