這篇文章主要介紹“Python怎么實(shí)現(xiàn)自行車租賃數(shù)據(jù)分析”,在日常操作中,相信很多人在Python怎么實(shí)現(xiàn)自行車租賃數(shù)據(jù)分析問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對(duì)大家解答”Python怎么實(shí)現(xiàn)自行車租賃數(shù)據(jù)分析”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!
在壽陽等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供做網(wǎng)站、網(wǎng)站制作 網(wǎng)站設(shè)計(jì)制作定制設(shè)計(jì),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),全網(wǎng)整合營銷推廣,外貿(mào)網(wǎng)站制作,壽陽網(wǎng)站建設(shè)費(fèi)用合理。
數(shù)據(jù)來源
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
bike = pd.read_csv(open(r'D:\python數(shù)據(jù)分析\數(shù)據(jù)\bike.csv'))
bike.head()
問題探索
數(shù)據(jù)清洗
bike.isnull().sum()
bike.dtypes
bike['datetime'] = pd.to_datetime(bike['datetime'])bike.dtypes
bike = bike.set_index('datetime') #將datetime字段設(shè)置為DataFrame的索引,成為時(shí)間序列數(shù)據(jù)bike.head()
bike.index #索引
bike.tail()
數(shù)據(jù)探索
y_bike = bike.groupby(lambda x: x.year).mean() # 降采樣年份數(shù)據(jù)y_bike['count']
y_bike['count'].plot(kind='bar') # 繪制柱狀圖
m_bike = bike.resample('M', kind='period').mean() # 重采樣到月份,類型為時(shí)期類型
m_bike.head()
fig, axes = plt.subplots(2, 1) #兩行一列m_bike['2011']['count'].plot(ax=axes[0],sharex=True) #貢獻(xiàn)X軸m_bike['2012']['count'].plot(ax=axes[1])
bike['day'] = bike.index.day
bike['hour'] = bike.index.hour # 單獨(dú)存儲(chǔ)日和時(shí)的數(shù)據(jù)
bike.head()
d_bike = bike.groupby('day')['count'].mean() #對(duì)day字段分組統(tǒng)計(jì)
d_bike
d_bike.plot() # 自行車每日租賃數(shù)分布
h_bike = bike.groupby('hour')['count'].mean() #對(duì)hour字段分組統(tǒng)計(jì)
h_bike
h_bike.plot() # 自行車每小時(shí)租賃數(shù)分布
work_bike = bike.groupby('workingday')['count'].mean()
work_bike #對(duì)workingday字段分組統(tǒng)計(jì)
work_bike.plot(kind='bar')
weather_bike = bike.groupby('weather')['count'].mean()
weather_bike #對(duì)weather字段分組統(tǒng)計(jì)
weather_bike.plot(kind='bar')
到此,關(guān)于“Python怎么實(shí)現(xiàn)自行車租賃數(shù)據(jù)分析”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!