<jupyter_start><jupyter_text><jupyter_code>#Importing Pandas
#
import pandas as pd

#Importing Numpy
#
import numpy as np
# Creating a Dataframe from Autolib_dataset.csv file
#

df_ec = pd.read_csv('/content/Autolib_dataset.csv', delimiter = ',')
df_ec.head()
# Accesssing the info about the dataset
#
df_ec.info()
# Listing the columns in a numPy array
#
df_ec.columns
#  Counting the no. of missing values
#
np.count_nonzero(df_ec.isnull())
# Checking the missing values in individual columns in our dataframe
#
num_rows = df_ec.shape[0]
num_missing = num_rows - df_ec.count() 
num_missing
# Drop the columns that have missing values

df_ec_2 = df_ec.drop(columns = ['Displayed comment', 'Scheduled at'])
df_ec_2
# Dropping other unnecessary columns that we don't need in our dataframe 
#
df_ec_3 = df_ec_2.drop(columns = ['Cars', 'Address', 'Geo point'])
df_ec_3<jupyter_output><empty_output><jupyter_text>The cars column is redundant with Bluecar counter, always the same value.So the cars column can be removed.<jupyter_code># Identify if there are any duplicates
#
df_ec_3.duplicated()<jupyter_output><empty_output><jupyter_text>There are no duplicates<jupyter_code># Removing white spaces, converting to upper case in all columns
#
df_ec_3.columns = df_ec_3.columns.str.strip().str.upper().str.replace(' ', '_')
df_ec_3
#  The most popular hour of the day for picking up a shared electric car (Bluecar)
#
pop_hr = df_ec_3 [(df_ec_3.STATUS == 'ok')]

pop_hr.groupby(['HOUR'])['BLUECAR_COUNTER'].count().sort_values(ascending = True).head(5)<jupyter_output><empty_output><jupyter_text>**The most popular hours to pick up a Bluecar is between 1pm - 2pm**<jupyter_code># QN 1

# The 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.
#

pop_hr_paris = df_ec_3 [(df_ec_3.STATUS == 'ok') & (df_ec_3.CITY == 'Paris')]

pop_hr_paris.groupby(['HOUR'])['BLUECAR_COUNTER'].count().sort_values(ascending = True).head(3)<jupyter_output><empty_output><jupyter_text>**The most popular hours to pick up a Bluecar in Paris is between 11am - 2pm**<jupyter_code># QN 2

# What is the most popular hour for returning cars?
#
df_ec_3.groupby(['HOUR'])['BLUECAR_COUNTER'].count().sort_values(ascending = False).head(5)<jupyter_output><empty_output><jupyter_text>**The most popular hour to return cars is between 9pm - 10pm**<jupyter_code># QN 3A

# What station is the most popular?
#
df_ec_3.groupby(['PUBLIC_NAME'])['SLOTS'].count().sort_values(ascending = False).head(1)
# QN 3B

# What station is the most popular at the most popular picking hour?
#
pop_p_hr = df_ec_3 [(df_ec_3.HOUR == 1)]

pop_p_hr.groupby(['PUBLIC_NAME'])['SLOTS'].count().sort_values(ascending = False).head(16)
# QN 4A

# What postal code is the most popular for picking up Blue cars? 
#
pop_pcode = df_ec_3[(df_ec_3.STATUS == 'ok')]

pop_pcode.groupby(['POSTAL_CODE'])['BLUECAR_COUNTER'].count().sort_values(ascending = True).head(3)<jupyter_output><empty_output><jupyter_text>The most popular postal code is **'94100'**<jupyter_code># QN 4B

# Does the most popular station belong to that postal code?
#
df_ec_3.groupby(['PUBLIC_NAME'])['BLUECAR_COUNTER'].count().sort_values(ascending = True).head(3)
# QN 4C

# At the most popular picking hour?
#
pop_pcode = df_ec_3[(df_ec_3.STATUS == 'ok') & (df_ec_3.HOUR == 1)]

pop_pcode.groupby(['POSTAL_CODE'])['BLUECAR_COUNTER'].count().sort_values(ascending = True).head(10)
#  The most popular hour of the day for picking up a Utilib
#
pop_hr_u = df_ec_3 [(df_ec_3.STATUS == 'ok')]

pop_hr_u.groupby(['HOUR'])['UTILIB_COUNTER'].count().sort_values(ascending = True).head(5)<jupyter_output><empty_output><jupyter_text>**The most popular hours to pick up a Utilib is between 1am - 2am**<jupyter_code># What is the most popular hour for returning a Utilib?
#

df_ec_3.groupby(['HOUR'])['UTILIB_COUNTER'].count().sort_values(ascending = False).head(5)<jupyter_output><empty_output><jupyter_text>**The most popular hour to return Utilib is between 9pm - 10pm**<jupyter_code>#  The most popular hour of the day for picking up a Utilib 1.4
#
pop_hr_u = df_ec_3 [(df_ec_3.STATUS == 'ok')]

pop_hr_u.groupby(['HOUR'])['UTILIB_1.4_COUNTER'].count().sort_values(ascending = True).head(5)<jupyter_output><empty_output><jupyter_text>**The most popular hours to pick up a Utilib 1.4 is between 1am - 2am**<jupyter_code># What is the most popular hour for returning a Utilib 1.4?
#

df_ec_3.groupby(['HOUR'])['UTILIB_1.4_COUNTER'].count().sort_values(ascending = False).head(5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13452718934265123, 'fraction_numerical': 0.019218169906093034, 'mean_word_length': 6.2239747634069404, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '137547', 'license': 'MIT', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1704, 'n_words': 419, 'path': 'Electric_Car_Sharing_Service_Company.ipynb', 'repo_name': 'ndungu96/IP-wk-4-electric-car-sharing-service-company', 'size': '4579'}