a blue day

today I am despressed due to my carelessness in my today's exams!
It seems a joke!Even I haven't thought it in my dream.
but it happens at last!
It is worth laughing that I hope the help of friend when I come accross difficulties.
Always in my heart i regard myself as a independ men .But it turn out to be that I am just a commam person,a part of the society.
we all are human being,and we all need friendship. It is what I have learned today!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
保留原本功能优化以下代码import pandas as pd import numpy as np import matplotlib.pyplot as plt # 1.读取并查看数据 bike_day = pd.read_csv("C:/Users/15020/Desktop/26.bike_day.csv") print(bike_day.head(5)) # 前5行 print(bike_day.tail(2)) #后2行 #2.处理数据并导出到文件 bike_day_user = bike_day[['instant','dteday','yr', 'casual', 'registered']].dropna() bike_day_user.to_csv('bike_day_user.txt', sep=' ',index=False, header=False) #3.读取数据并添加新列并导出到新文件 bike_day_user = pd.read_csv('bike_day_user.txt', sep=' ', header=None, names=['instant','dteday','yr', 'casual',"registered"]) bike_day_user['cnt'] = bike_day_user['casual'] + bike_day_user['registered'] bike_day_user.to_excel('bike_day_user_cnt.xlsx', index=False) #4.读取数据并进行统计 bike_day_user_cnt = pd.read_excel('bike_day_user_cnt.xlsx') print('cnt最大值:',bike_day_user_cnt['cnt'].max()) print('ent最小值:',bike_day_user_cnt['cnt'].min()) print('2011号cnt年平均值:',bike_day_user_cnt[bike_day_user_cnt['yr'] == 0]['cnt'].mean()) print('2012年cnt年平均值:',bike_day_user_cnt[bike_day_user_cnt['yr'] == 1]['cnt'].mean()) print('2011年月严始值:', bike_day_user_cnt[bike_day_user_cnt['yr'] == 0].groupby('mnth')['cnt'].mean()) print('2022年月平均值:', bike_day_user_cnt[bike_day_user_cnt['yr'] == 1].groupby('mnth')['cnt'].mean()) # 5.可视化并保存图像 fig, ax = plt.subplots() ax.barh(bike_day_user_cnt['mnth'], bike_day_user_cnt[bike_day_user_cnt['yr'] == 0].groupby('mnth')['cnt'].mean(), color='blue', label='2011') ax.barh(bike_day_user_cnt['mnth'], bike_day_user_cnt[bike_day_user_cnt['yr'] == 1].groupby('mnth')['cnt'].mean(), color='lightblue', label='2012') ax.set_yticks(np.arange(1,13)) ax.set_yticklabels(['Jan','Feb','Mar', 'Apr', 'May','Jun','Jul','Aug', 'sep', 'Oct','Nov','Dec']) ax.set_xlabel('Average number of shared bike users') ax.set_title('Monthly Average Number of Shared Bike Users in 2011-2012') ax.legend() fig.savefig('bike_day_user_cnt.png', dpi=300)
06-03

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值