Skip to content
London Bike
#Import pandas,zipfile,& kaggle libraies
import pandas as pd
#Read CSV
bikes = pd.read_csv("london_merged.csv")
#Explore Data
bikes.info()
bikes.shape
bikes
Hidden output
#Unique count on weather_code
bikes.weather_code.value_counts()
#Unique count on season
bikes.season.value_counts()
# Update column names
new_colums_dict ={
'timestamp':'time',
'cnt':'count',
't1':'temp_real_C',
't2':'temp_feels_like_C',
'hum':'humidity_percent',
'wind_speed':'wind_speed_kph',
'weather_code':'weather',
'is_holiday':'is_holiday',
'is_weekend':'is_weekend',
'season':'season'
}
# Renaming the columns to the specified column names
bikes.rename(new_colums_dict, axis=1, inplace=True)
# Change to %
bikes.humidity_percent = bikes.humidity_percent / 100
#Season dictionary int to str
season_dict = {
'0.0':'Spring',
'1.0':'Summer',
'2.0':'Autumn',
'3.0':'Winter'
}
bikes.season = bikes.season.astype(str)
bikes.season = bikes.season.map(season_dict)
#Weather dictionary int to str
weather_dict = {
'1.0':'Clear',
'2.0':'Scattered Clouds',
'3.0':'Broken Clouds',
'4.0':'Cloudy',
'7.0':'Rain',
'10.0':'Rain with Thunderstorm',
'26.0':'Snowfall',
}
bikes.weather = bikes.weather.astype(str)
bikes.weather = bikes.weather.map(weather_dict)
#Check dataframe changes
bikes.head()
#Final dataframe to Excel file for Tableau viz
bikes.to_excel('london_bike_final.xlsx', sheet_name='Data')