嘿所有我正在编写一个代码,它接受用户输入并使用Pandas模块更新excel电子表格。 ere是我的代码片段
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时,我遇到了2个问题:
Upcoming events:
Date 2017-09-16 00:00:00
Time 14:00:00
Event Man U v.s Arsenal
Bookmaker Coral
Bookmaker Stake 2
Bookmaker Odds 1.4
Exchange Smarkets
Exchange Stake 3
Exchange Liability 5
Exchange Odds 2
Profit 40
Name: 1, dtype: object
如何摆脱00:00:00
和Name: 1, dtype object?
任何和所有帮助表示赞赏!