我是靠谱客的博主 诚心黑裤,这篇文章主要介绍天气数据处理,缺失值异常处理,现在分享给大家,希望可以做个参考。

lows_highs.py

import csv
from matplotlib import pyplot as plt
from datetime import datetime

filename='death_valley_2014.csv'
with open(filename) as f:
    reader=csv.reader(f)
    header_row=next(reader)

    highs=[]
    dates=[]
    lows=[]
    for row in reader:
        try:
            current_date=datetime.strptime(row[0],"%Y-%m-%d")
            high=int(row[1])
            low=int(row[3])
        except ValueError:
            print(current_date,'missing date')
        else:
            dates.append(current_date)
            highs.append(high)
            lows.append(low)

fig=plt.figure(dpi=128,figsize=(10,6))
plt.plot(dates,highs,c='red',alpha=0.5)

plt.plot(dates,lows,c='blue',alpha=0.5)
plt.fill_between(dates,highs,lows,facecolor='blue',alpha=0.1)

plt.title("Daily high temperature 2014",fontsize=24)
plt.xlabel('',fontsize=16)
fig.autofmt_xdate()
plt.ylabel("Temperature ",fontsize=16)
plt.tick_params(axis='both',which='major',labelsize=16)
plt.show()

运行结果

 

最后

以上就是诚心黑裤最近收集整理的关于天气数据处理,缺失值异常处理的全部内容,更多相关天气数据处理内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部