【发布时间】:2019-10-28 14:47:47
【问题描述】:
请帮帮我,我需要按当前日期排序的数据,运行时显示:
空数据框
列:[DATE、TIME、FROM、TO、Vehicle、REQUESTOR]
索引:[]
这是我的代码:
import tkinter as tk
import datetime
from tkinter import *
import pandas as pd
class Root(Tk):
def __init__(self):
super(Root, self).__init__()
self.geometry("900x500")
now = datetime.datetime.now()
print("Current date and time : ")
print(now.strftime("%Y-%m-%d"))
self.label1 = tk.Label(self, text=now.strftime("%Y-%m-%d"), font="Helvatica 20 bold")
self.label1.place(x=750, y=0)
self.data = pd.read_excel(r'pandas_simple.xlsx', sheet_name="UNO")
self.booleans = []
self.booleans[:]
self.numero1 = pd.Series(self.booleans)
self.numero1 = self.data.DATE == now.strftime
self.numero1.head()
self.data[self.numero1]
print(self.data[self.numero1])
self.current = tk.Label(self, text=self.data[self.numero1], bg="ORANGE", width=68, height=13)
self.current.place(x=1, y=3)
jona = Root()
jona.title("BOOKING CHORVA")
jona.mainloop()
【问题讨论】:
-
好吧,我不太确定你想在这里实现什么。你不能对空数据框进行排序吗?请更清楚地说明您要做什么。
-
我在这个文件 'pandas_simple.xlsx' 中有一个 excel 数据,我想按当前日期对其进行排序(因为那里有一个名为 DATE 的数据框)并在我的 tkinter 中显示数据。
-
然后试试
df.sort_values('date',ascending=True,inplace=True)
标签: python excel python-3.x pandas dataframe