【发布时间】:2021-09-03 23:48:51
【问题描述】:
我是一名学生,我正在学习熊猫。
我创建了名为 Student_Record.xlsx 的 excel 文件(使用 microsoft excel)
我想用 pandas 创建新文件
import pandas as pd
df = pd.read_excel(r"C:\Users\sudarshan\Desktop\Student_Record.xlsx")
df.head()
df.to_excel(r"C:\Users\sudarshan\Desktop\Output.xlsx",index=False)
我在 pandas 中打开了文件,然后用不同的名称将文件保存回 excel(文件名 = 输出)
我将文件保存回 Excel,但是当我在 MS.Excel 上打开文件(输出)时,列(DOB 和 YOP)附有日期的时间戳。
请告诉我如何只打印日期?(我希望输出文件及其内容与原始文件完全相同)
希望得到一些帮助/支持。 谢谢
【问题讨论】:
-
请do not post images 提供您的数据。您可以包含code that creates a dataframe or the output of
print(df)(或允许重现示例的几行和几列)
标签: python excel pandas datetime