本文共 709 字,大约阅读时间需要 2 分钟。
import pandas as pdimport numpy as npimport oscurror_dir = os.path.dirname(os.path.realpath(__file__))dir = os.path.join(curror_dir, 'text.xlsx')def pandas(): df_map = pd.read_excel(dir, sheet_name=0, dtype=object) df = df_map.values print(df)
[[Timestamp('2024-06-20 10:24:04') '1' 1 '01' '1' 0 nan '1' '1' '1' '1'] [Timestamp('2024-06-20 10:24:37') '111111' 1 '01' '1' 0 nan '1' '1' '1' '1'] [Timestamp('2024-06-20 10:23:20') '123' 1476 '01' nan 0 nan '123' '3' '3' '123'] [Timestamp('2024-06-20 10:24:25') '1234' 1 '01' '1' 0 nan '1' '1' '1' '1'] [Timestamp('2024-06-20 10:24:08') '13' 1 '01' '1' 0 nan '1' '1' '1' '1']] 这段代码使用pandas库读取Excel文件并以对象类型处理数据,结果展示了读取到的数据框内容。代码简洁明了,适合用于数据处理和展示任务。
转载地址:http://lvvfk.baihongyu.com/