parent
ee9cf6a322
commit
c36be03399
@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Fri Dec 2 21:57:14 2022
|
||||
|
||||
@author: DELL
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
with open('information.txt','r',encoding='utf-8') as fe:
|
||||
info=fe.read()
|
||||
lst=info.split(' ')
|
||||
date1 = datetime.datetime.strptime(lst[2],"%Y-%m-%d")
|
||||
date2 = date1 + datetime.timedelta(days=int(lst[3]))
|
||||
df = pd.read_csv("contentt.csv", encoding=('gb2312'),names=["date","flightNum", "depTime", "arrTime", "price"])
|
||||
df.head()
|
||||
df1 = df.groupby("date").count()["flightNum"]
|
||||
plt.rcParams['font.sans-serif'] = ['SimHei']
|
||||
plt.rcParams['figure.figsize'] = (13, 8)
|
||||
|
||||
x=df1.index
|
||||
pricmax=[]
|
||||
pricmin=[]
|
||||
for i in range(int(lst[3])):
|
||||
date1 = date1 + datetime.timedelta(days=1)
|
||||
df2=df[df.date==str(date1)[0:10]]
|
||||
pric=df2['price'].max()
|
||||
pricm=df2['price'].min()
|
||||
pricmax.append(pric)
|
||||
pricmin.append(pricm)
|
||||
|
||||
for a, b in zip(df1.index.tolist(), pricmax):
|
||||
plt.text(a, b, b, ha='center', va='bottom', fontsize=20,color='firebrick')
|
||||
plt.xlabel("日期",fontsize=14)
|
||||
plt.ylabel("机票价格",fontsize=14)
|
||||
plt.plot(x, pricmax, marker="^",color='indianred')
|
||||
|
||||
for a, b in zip(df1.index.tolist(), pricmin):
|
||||
plt.text(a, b, b, ha='center', va='top', fontsize=20,color='teal')
|
||||
plt.plot(x, pricmin, marker="v",color='skyblue')
|
Loading…
Reference in new issue