小奥的学习笔记

  • Home
  • Learning & Working
    • Speech Enhancement Notes
    • Programming language
    • Computer & DL
    • MOOC
  • Life
    • Life Time
    • Thinking & Comprehension
    • Volunteer
    • Plan
    • Travel
  • Footprints
  • GuestBook
  • About
    • About Me
    • 个人履历
    • 隐私策略
  1. 首页
  2. Study-notes
  3. Programming language
  4. Python
  5. 正文

python处理csv文件,以锡特卡气温为例

2017年10月22日 1479点热度 0人点赞 0条评论

high_low_mean.py

# -*- coding: utf-8 -*-
"""
Created on Sun Oct 22 18:19:57 2017
@author: dqhpl
"""
import csv
from matplotlib import pyplot as plt
from datetime import datetime#获取时间的包
filename = 'sitka_weather_2014.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)
    
    highs,dates, lows, means = [],[],[],[]
    for row in reader:
        try:
            current_date = datetime.strptime(row[0], "%Y-%m-%d")#转换为日期形式,格式记住
        
            low = int(row[3])
        
            high = int(row[1])
        
            mean = int(row[2])
        except ValueError:
            print(current_date, 'missing data')#如果有日期缺失数据提醒没有数据
        else:
            dates.append(current_date)
            lows.append(low)
            highs.append(high)#每一行第1列的数据加入(这个其实是第2列,真正的第1列是第0列)
            means.append(mean)
fig = plt.figure(dpi =128,figsize=(10,5))
plt.plot(dates, highs, c='red', alpha = 0.3)#alpha指定透明度,0是完全透明,1是完全不透明
plt.plot(dates, lows, c='blue', alpha =0.3)
plt.plot(dates, means, c='yellow')
plt.fill_between(dates, highs, lows, facecolor= 'blue', alpha=0.1)
#设置图像格式
plt.title("Daily high temperatures - 2014", fontsize = 14)
fig.autofmt_xdate()#绘制斜的日期标签
plt.ylabel("Temperature(F)", fontsize =10)
plt.savefig('temperature.png',  bbox_inces = 'tight')
#plt.show()#plt.show()打开matplotlib查看器,并显示绘制的图形
#    for index,column_header in enumerate(header_row):#enumerate()表示来获取每个元素的索引及其值
#       print(index, column_header)

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: Python python学习
最后更新:2017年10月22日

davidcheung

这个人很懒,什么都没留下

打赏 点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

搜索
欢迎关注我的个人公众号
最新 热点 随机
最新 热点 随机
DEEPFILTERNET:一种基于深度滤波的全频带音频低复杂度语音增强框架 奥地利匈牙利九日游旅程 论文阅读之Study of the General Kalman Filter for Echo Cancellation 小奥看房之鸿荣源珈誉府 杭州往返旅途及西溪喜来登和万怡的体验报告 2022年的第一篇碎碎念
奥地利匈牙利九日游旅程论文阅读之Study of the General Kalman Filter for Echo CancellationDEEPFILTERNET:一种基于深度滤波的全频带音频低复杂度语音增强框架
Opus编解码器简介 新青年报[New Youth]第八期(高考录取特刊)即将发布 世园会水舞(夜景) 今天在github上更新了几个小程序 2018 CSL 15th: Shandong Luneng Taishan F.C VS Shanghai Greenland Shenhua F.C 2010 S.V Beijing Travel 20:New Clothes Photo
标签聚合
学习 高中 生活 Java 算法 鸟哥的linux私房菜 linux python学习 leetcode Python
最近评论
davidcheung 发布于 5 个月前(02月09日) The problem has been fixed. May I ask if you can s...
tk88 发布于 5 个月前(02月07日) Hmm is anyone else having problems with the pictur...
cuicui 发布于 9 个月前(10月20日) :wink:
niming 发布于 10 个月前(09月19日) 同级校友,能刷到太巧了
davidcheung 发布于 2 年前(08月16日) 我得找一下我之前整理的word文档看一下,如果找到了我就更新一下这篇文章。
Nolan 发布于 2 年前(07月25日) 您的笔记非常有帮助。贴图不显示了,可以更新一下吗?
davidcheung 发布于 3 年前(06月19日) 到没有看webrtc的代码。现在主要在看我们公司的代码了。。。只是偶尔看一看webrtc的东西。。。
aobai 发布于 3 年前(03月13日) gain_change_hangover_ 应该是每三个block 只能够调整一次,这样保证每帧...
匿名 发布于 5 年前(12月30日) 烫
小奥 发布于 5 年前(12月12日) webRTC里面的NS本身我记得就是在C++里面呀

COPYRIGHT © 2025 小奥的学习笔记. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

陕ICP备19003234号-1

鲁公网安备37120202000100号