我是靠谱客的博主 诚心黑裤,最近开发中收集的这篇文章主要介绍天气数据处理,缺失值异常处理,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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()

运行结果

 

最后

以上就是诚心黑裤为你收集整理的天气数据处理,缺失值异常处理的全部内容,希望文章能够帮你解决天气数据处理,缺失值异常处理所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部