嘿,所有我正在写一个代码,接受用户的输入和更新excel电子表格使用熊猫模块。我有一段代码import pandas as pd
import time
import datetime as dt
df = pd.read_excel('test.xlsx')
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
def view_books():
option1 = True
while option1 == True:
choice = input("\nWhat would you like to view?:\n1) Entire spreadsheet\n2) Upcoming events\n3) Total profit\n")
if choice == "1":
print("\n",df)
option1 = False
elif choice == "2":
print("Upcoming events:\n")
for i in range(len(df['Date'])):
date = pd.to_datetime(df['Date'][i])
today = dt.datetime.today()
if date>today:
print(df.iloc[i],"\n")
else:
pass
option1 = False
elif choice == "3":
print("Total profit is: £",df["Profit"].sum())
option1 = False
elif choice != "1" or "2" or "3":
print("\nInvalid choice\n")
我的问题是,当我运行此函数并选择选项2时,我会遇到两个问题:
^{pr2}$
如何同时删除00:00:00和{}
感谢任何帮助!在