<jupyter_start><jupyter_text>**Instructions:** 1. **For all questions after 10th, Please only use the data specified in the note given just below the question**2. **You need to add answers in the same file i.e.  PDS_UberDriveProject_Questions.ipynb' and rename that file as 'Name_Date.ipynb'.You can mention the date on which you will be uploading/submitting the file.For e.g. if you plan to submit your assignment on 31-March, you can rename the file as 'STUDENTNAME_31-Mar-2020'**  Load the necessary libraries. Import and load the dataset with a name uber_drives .<jupyter_code>import pandas as pd 
import numpy as np
# Get the Data
data_uber_driver = pd.read_csv('uberdrive-1.csv')<jupyter_output><empty_output><jupyter_text>Q1. Show the last 10 records of the dataset. (2 point)<jupyter_code>data_uber_driver.tail(10)<jupyter_output><empty_output><jupyter_text>Q2. Show the first 10 records of the dataset. (2 points)<jupyter_code>data_uber_driver.head(10)<jupyter_output><empty_output><jupyter_text>Q3. Show the dimension(number of rows and columns) of the dataset. (2 points)<jupyter_code>data_uber_driver.shape<jupyter_output><empty_output><jupyter_text>Q4. Show the size (Total number of elements) of the dataset. (2 points)<jupyter_code>data_uber_driver.size<jupyter_output><empty_output><jupyter_text>Q5. Print the information about all the variables of the data set. (2 points)<jupyter_code>data_uber_driver.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 1155 entries, 0 to 1154
Data columns (total 7 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   START_DATE*  1155 non-null   object 
 1   END_DATE*    1155 non-null   object 
 2   CATEGORY*    1155 non-null   object 
 3   START*       1155 non-null   object 
 4   STOP*        1155 non-null   object 
 5   MILES*       1155 non-null   float64
 6   PURPOSE*     653 non-null    object 
dtypes: float64(1), object(6)
memory usage: 63.3+ KB<jupyter_text>Q6. Check for missing values. (2 points) -  Note: Output should be boolean only.<jupyter_code>data_uber_driver.isna()<jupyter_output><empty_output><jupyter_text>Q7. How many missing values are present? (2 points)<jupyter_code>data_uber_driver.isna().sum().sum()<jupyter_output><empty_output><jupyter_text>Q8. Get the summary of the original data. (2 points). Hint:Outcome will contain only numerical column.<jupyter_code>data_uber_driver.describe()<jupyter_output><empty_output><jupyter_text>Q9. Drop the missing values and store the data in a new dataframe (name it"df") (2-points) Note: Dataframe "df" will not contain any missing value<jupyter_code>df = data_uber_driver.dropna()<jupyter_output><empty_output><jupyter_text>Q10. Check the information of the dataframe(df). (2 points)<jupyter_code>df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 653 entries, 0 to 1154
Data columns (total 7 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   START_DATE*  653 non-null    object 
 1   END_DATE*    653 non-null    object 
 2   CATEGORY*    653 non-null    object 
 3   START*       653 non-null    object 
 4   STOP*        653 non-null    object 
 5   MILES*       653 non-null    float64
 6   PURPOSE*     653 non-null    object 
dtypes: float64(1), object(6)
memory usage: 40.8+ KB<jupyter_text>Q11. Get the unique start destinations. (2 points) Note: This question is based on the dataframe with no 'NA' values Hint- You need to print the unique destination place names in this and not the count.<jupyter_code>df['START*'].unique()<jupyter_output><empty_output><jupyter_text>Q12. What is the total number of unique start destinations? (2 points) Note: Use the original dataframe without dropping 'NA' values<jupyter_code>data_uber_driver['START*'].nunique()<jupyter_output><empty_output><jupyter_text>Q13. Print the total number of unique stop destinations. (2 points) Note: Use the original dataframe without dropping 'NA' values.<jupyter_code>data_uber_driver['STOP*'].unique().size<jupyter_output><empty_output><jupyter_text>Q14. Print all the Uber trips that has the starting point of San Francisco. (2 points) Note: Use the original dataframe without dropping the 'NA' values. Hint: Use the loc function<jupyter_code>data_uber_driver[data_uber_driver['START*']=='San Francisco']<jupyter_output><empty_output><jupyter_text>Q15. What is the most popular starting point for the Uber drivers? (2 points) Note: Use the original dataframe without dropping the 'NA' values. Hint:Popular means the place that is visited the most<jupyter_code>data_uber_driver['START*'].value_counts().idxmax()<jupyter_output><empty_output><jupyter_text>Q16. What is the most popular dropping point for the Uber drivers? (2 points) Note: Use the original dataframe without dropping the 'NA' values. Hint: Popular means the place that is visited the most<jupyter_code>data_uber_driver['STOP*'].value_counts().idxmax()<jupyter_output><empty_output><jupyter_text>Q17. List the most frequent route taken by Uber drivers. (3 points) Note: This question is based on the new dataframe with no 'na' values. Hint-Print the most frequent route taken by Uber drivers (Route= combination of START & END points present in the Data set).<jupyter_code>df.groupby(['START*', 'STOP*']).size().sort_values(ascending=False)<jupyter_output><empty_output><jupyter_text>Q18. Print all types of purposes for the trip in an array. (3 points) Note: This question is based on the new dataframe with no 'NA' values.<jupyter_code>df['PURPOSE*']<jupyter_output><empty_output><jupyter_text>Q19. Plot a bar graph of Purpose vs Miles(Distance). (3 points) Note: Use the original dataframe without dropping the 'NA' values. Hint:You have to plot total/sum miles per purpose<jupyter_code>import matplotlib.pyplot as plt
fig = plt.figure(figsize=(19,5))
ax = fig.add_axes([0,0,1,1])
# replacing na 'PURPOSE' values  
data_uber_driver["PURPOSE*"].fillna("NO_PURPOSE_PROVIDED", inplace = True) 
# replacing na 'MILES' values 
data_uber_driver["MILES*"].fillna("NO_MILES_PROVIDED", inplace = True) 
ax.bar(data_uber_driver['PURPOSE*'],data_uber_driver['MILES*'])
plt.show()<jupyter_output><empty_output><jupyter_text>Q20. Print a dataframe of Purposes and the distance travelled for that particular Purpose. (3 points) Note: Use the original dataframe without dropping "NA" values<jupyter_code>data_uber_driver.groupby(by=["PURPOSE*"]).sum()<jupyter_output><empty_output><jupyter_text>Q21. Plot number of trips vs Category of trips. (3 points) Note: Use the original dataframe without dropping the 'NA' values. Hint : You can make a countplot or barplot.<jupyter_code># import seaborn as sns
# sns.countplot(x='CATEGORY*',data=data_uber_driver)
data_uber_driver['CATEGORY*'].value_counts().plot(kind='bar',figsize=(19,7),color='red');<jupyter_output><empty_output><jupyter_text>Q22. What is proportion of trips that is Business and what is the proportion of trips that is Personal? (3 points) Note:Use the original dataframe without dropping the 'NA' values. The proportion calculation  is with respect to the 'miles' variable. Hint:Out of the category of trips, you need to find percentage wise how many are business and how many are personal on the basis of miles per category.<jupyter_code>data_uber_driver['CATEGORY*'].value_counts(normalize=True)*100<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10396106529674193, 'fraction_numerical': 0.0259564688387184, 'mean_word_length': 5.30690537084399, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 93, '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': '23', 'dir': 'jupyter-structured-clean-dedup', 'id': '7013', 'license': 'MIT', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2382, 'n_words': 751, 'path': 'M1 Python For Data Science/Week_3_Python_For_Data_Science_Data_Visulization_With_Python/PDS_UberDriveProject_Question.ipynb', 'repo_name': 'fborrasumh/greatlearning-pgp-dsba', 'size': '7397'}