<jupyter_start><jupyter_text><jupyter_code>#import libraries
import pandas as pd
import numpy as np
#load the csv file
autolib_df = pd.read_csv('Autolib_dataset (2).csv')
autolib_df.head(5)
##accessing the dataset info
autolib_df.info()
#check if there are any null values
autolib_df.isnull().values.any()
#finding the null values
autolib_df.isnull().sum()
#shape of the dataset
autolib_df.shape
#drop columns by dropping the columns that contain null values
autolib_df_comment = autolib_df.drop(['Displayed comment'], axis=1, inplace =True)
autolib_df_comment
#drop 'Scheduled at'
autolib_df_Scheduled = autolib_df.drop(['Scheduled at'], axis=1, inplace=True)
autolib_df_Scheduled
#confirming whether changes have been made
autolib_df.isnull().sum()
#accessing all the columns
autolib_df.columns
#changing the columns into lowercase
autolib_df.rename(columns={'Address':'address', 'Cars':'cars', 'Bluecar counter':'bluecar counter', 
                           'Utilib counter':'utilib counter', 'Utilib 1.4 counter':'utilib 1.4 counter',
                           'Charge Slots':'charge slots', 'Charging Status':'charging status', 
                           'City':'city', 'ID':'id', 'Kind':'kind', 'Geo point':'geo point', 
                           'Postal code':'postal code', 'Public name':'public name',
                           'Rental status':'rental status', 'Slots':'slots',
                           'Station type':'station type', 'Status':'status', 
                           'Subscription status':'subscription status',
                      }, inplace = True)
autolib_df.head()
autolib_df.head()
#find shape of the new dataset
autolib_df.shape
#add datetime column

autolib_df['datetime'] = pd.to_datetime((autolib_df.year*10000+autolib_df.month*100+autolib_df.day).apply(str),format='%Y%m%d')
datetime
autolib_df.head()
#most popular hour of the day for picking up a shared electric car (Bluecar) in the city of Paris over the month of April 2018
# city_hour = autolib_df['city'] == 'Paris'
# autolib_df.loc[city_hour].head()

result = autolib_df.groupby(['datetime', 'bluecar counter', city_hour])['hour'].value_counts()
result
#What is the most popular hour for returning cars
popular_hour = autolib_df.groupby(['hour', 'cars'])['hour'].agg(['count']).sort_values(by='count', ascending=False)
popular_hour.head(1)
#What station is the most popular station
#overall

popular_station = autolib_df.groupby(['station type'])['station type'].agg(['count']).sort_values(by='count', ascending=False)
popular_station.head(1)
#What postal code is the most popular for picking up Blue cars
popular_postal = autolib_df.groupby(['postal code', 'bluecar counter'])['postal code'].agg(['count']).sort_values(by='count')
popular_postal.head(1)
#most popular picking hour for the postal code
code_hour = autolib_df.groupby(['hour', 'postal code'])['hour'].agg(['count']).sort_values(by='count', ascending=False)
code_hour.head(1)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup