文章目录
0 前言
Hi,大家好,这里是丹成学长,今天向大家介绍一个学长做的数据分析项目,基于大数据的共享单车数据分析
毕设帮助,开题指导,资料分享,疑问解答(见文末)
🧿 选题指导, 项目分享:见文末
1 项目背景
公共交通工具的“最后一公里”是城市居民出行采用公共交通出行的主要障碍,也是建设绿色城市、低碳城市过程中面临的主要挑战。
共享单车(自行车)企业通过在校园、地铁站点、公交站点、居民区、商业区、公共服务区等提供服务,完成交通行业最后一块“拼图”,带动居民使用其他公共交通工具的热情,也与其他公共交通方式产生协同效应。
共享单车是一种分时租赁模式,也是一种新型绿色环保共享经济。自2014年ofo首次提出共享单车概念,至今已陆续产生了25个共享单车品牌,与传统的有桩借还自行车相比,无桩的共享单车自由度更高,广受用户好评。
本次分析拟取2017年5月中旬某共享单车在北京地区的车辆订单数据,从时间、空间、频次三个维度进行分析,对该品牌共享单车的发展方向提出改善性意见。
2 项目分析思维导图
3 项目分析具体步骤
3.1 读取数据
from geopy.geocoders import BaiduV3
from geopy import distance
import geohash as gh
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pyecharts.charts import *
from pyecharts import options as opts
import datetime
%matplotlib inline
fpath="../data/shared-bakes/train.csv"
df_shared_bakes=pd.read_csv(fpath,encoding="gbk")
df_shared_bakes.head()
3.2 数据分析
3.1.1 数据预处理——每日使用量分析
df_shared_bakes_time_sorted=df_shared_bakes.sort_values(by="starttime")
df_shared_bakes_time_sorted.head()
#完整数据的时间跨度为2017-5-10至2017-5-24,历时15天
early=df_shared_bakes_time_sorted.iloc[0,:]
last=df_shared_bakes_time_sorted.iloc[-1,:]
print(early.starttime)
print(last.starttime)
df_shared_bakes_time_in_range=df_shared_bakes_time_sorted.loc[df_shared_bakes_time_sorted["starttime"]<"2017-05-17",:]
df_shared_bakes_time_in_range.iloc[-1,:]
#提取连续7天数据的1%用于时间维度的分析
df_shared_bakes_data_used=df_shared_bakes_time_in_range.loc[df_shared_bakes_time_in_range.index%100==0,:]
df_shared_bakes_data_used.info()
#2017-05-10是星期三
#对比7天内每天的用户总量,分析工作日与周末的使用量是否存在差异
df_used_by_date=df_shared_bakes_data_used
a=df_used_by_date["starttime"].str.split(" ",expand=True)
#a
df_used_by_date.loc[:,"startdate"]=a.loc[:,0]
df_used_by_date.loc[:,"startetime"]=a.loc[:,1]
#df_used_by_date.head()
s_used_by_date=df_used_by_date.groupby("startdate").count()["userid"]
s_used_by_date
3.1.2 连续7天的单日使用分析结论
- 工作日相较于周末使用量更多
- 分别比较工作日与周末的使用量,整体趋势为稳步增长趋势
#工作日比周末(13,14日)的使用量更多
bar_used_by_date=(Bar()
.add_xaxis(list(s_used_by_date.index))
.add_yaxis("每日单车使用次数/100",list(s_used_by_date))
.set_global_opts(
title_opts={
"text":"连续7天的单日使用量统计","subtext":"取连续7天数据的1%进行统计"})
)
bar_used_by_date.render_notebook()
#工作日平均每天的使用量占比约为54.23%,周末平均每天使用量占比45.77%
workday_used_mean=s_used_by_date[s_used_by_date.index.isin(["2017-05-10","2017-05-11","2017-05-12","2017-05-15","2017-05-16"])].sum()/5
weekend_used_mean=s_used_by_date[s_used_by_date.index.isin(["2017-05-13","2017-05-14"])].sum()/2
#print(workday_used_mean)
#print(weekend_used_mean)
weekend_pct=round(weekend_used_mean*100/(weekend_used_mean+workday_used_mean),2)
workday_pct=round(workday_used_mean*100/(weekend_used_mean+workday_used_mean),2)
pie_used_data=[["workday "+str(workday_pct)+"%",workday_used_mean],["weekend "+str(weekend_pct)+"%",weekend_used_mean]]
pie_used=(Pie()
.add("",pie_used_data,center=["35%","50%"],radius=[0,175])
.set_global_opts(title_opts=opts.TitleOpts(title="工作日与周末平均使用量占比统计")))
p