You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import font_manager
font_path = r'E:\PycharmProjects\pythonProject\simsun.ttc'
font_prop = font_manager.FontProperties(fname=font_path)
#支持中文显示
'''
mpl.rcParams['font.family'] = 'Kaiti'
# 使用非 unicode 的负号,当使用中文时候要设置
mpl.rcParams['axes.unicode_minus'] = False
# %matplotlib inline
'''
data = pd.read_csv(r'E:\PycharmProjects\pythonProject\航班信息\airport-ontime.csv')
# data.info()
#将Unnamed这列删除
data.dropna(axis=1, how='all', inplace=True)
# data.info()
#查看是否有重复数据
data.duplicated().any()
data.drop_duplicates(inplace=True)
# data.info()
# 统计起飞是否延迟 饼图
# print(data['DEP_DEL15'].head())
dep_data = data['DEP_DEL15'].dropna()
dep_delay = dep_data.value_counts()
dep_delay.name = ''
dep_delay.plot(kind='pie', labels=['起飞不延迟', '起飞延迟'], autopct='%.2f', textprops={'fontproperties': font_prop})
plt.title('起飞延迟不延迟情况', {'fontproperties': font_prop})
plt.show()