<jupyter_start><jupyter_text><jupyter_code>#Week 4 IP 
#We will import the libraries we need 
import pandas as pd
import numpy as np

# Creating the dataframe from a url to the csv file 
data_df = pd.read_csv("http://bit.ly/autolib_dataset",index_col = 0, dtype = {'year':str, 'month': str, 'day': str,'hour':str, 'minute': str} )
data_df
#We will now count the number of non-missing values
data_df.count()
#We will now determine the no. of missing values in our dataset

data_df_missing= len(data_df) - data_df.count()
data_df_missing
data_df.info()
data_df.shape

#We will now drop duplicates 
data_df = data_df.drop_duplicates()
data_df
#We will now standardize column names so we can remove unnecesary columns including the 2 with alot of null values
data_df.columns = map (str.lower,data_df.columns)
columns = ['Cars','Bluecar_counter','Utilib_counter','Utilib_1.4_counter','Charge_slots','Charging_status','City','Displayed_comment','ID','Kind','Geo_point','Postal_code', 'Public_Name','Rental_Status','Scheduled_at','Slots','Station_type','Status','Subscription_status','Year','Month','Day','Hour','Minute']
data_df.columns = columns

data_df.head(10)
#Removing unnecesary columns
data_df = data_df.drop(columns = ['Displayed_comment', 'Geo_point', 'Public_Name', 'Scheduled_at','Subscription_status'])
data_df
#We will check for null values again
data_df_missing= len(data_df) - data_df.count()
data_df_missing
#We will now convert the last 4 into datetime then drop them
data_df['date'] = data_df.Year.str.cat([data_df.Month,data_df.Day],sep = '/')
data_df['time'] = data_df.Hour.str.cat([data_df.Minute],sep = ':')
data_df['date_time'] = data_df.date.str.cat([data_df.time],sep = ' ')
data_df = data_df.drop(columns = ['Year','Month','Day','Minute'])
data_df
# We will now only filter the values whose status is ok
data_df = data_df[data_df['Status'] == 'ok']
data_df
#We will check again for null values
data_df_missing= len(data_df) - data_df.count()
data_df_missing
#What is the most popular hour for returning cars?<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1389023797960175, 'fraction_numerical': 0.003885381253035454, 'mean_word_length': 6.953667953667954, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '308255', 'license': 'MIT', 'n_tokens_mistral': 718, 'n_tokens_neox': 707, 'n_words': 183, 'path': 'Moringa_Data_Science_Prep_W4_Independent_Project_2021_05_Beatrice_Kiplagat_Python_Notebook.ipynb', 'repo_name': 'beatricekiplagat/Week-4-Independent-Project', 'size': '2059'}