[英]How do I put today's date in the first column of every row in Python's dataframe?
I use the following code to move data from one Excel file to another:我使用以下代码将数据从一个 Excel 文件移动到另一个:
import pandas as pd
inventory=pd.read_excel('Original_File.xlsx', skiprows=3)
inventory.to_excel('New_File.xlsx', index=False)
How do I place today's date in the first column of every row that contains data in New_File.xlsx?如何将今天的日期放在包含 New_File.xlsx 数据的每一行的第一列中?
Like this:像这样:
import pandas as pd
from datetime import datetime
inventory=pd.read_excel('Original_File.xlsx', skiprows=3)
inventory.insert(0, 'today_date', datetime.today().strftime('%Y-%m-%d'))
inventory.to_excel('New_File.xlsx', index=False)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.