<jupyter_start><jupyter_text>Assignment 01: Evaluate the FAA Dataset*The comments/sections provided are your cues to perform the assignment. You don't need to limit yourself to the number of rows/cells provided. You can add additional rows in each section to add more lines of code.**If at any point in time you need help on solving this assignment, view our demo video to understand the different steps of the code.***Happy coding!*** * *  1: VIew and import the dataset<jupyter_code>#Import necessary libraries
import pandas as pd
#Import the FAA (Federal Aviation Authority) dataset
df_faa_dataset = pd.read_csv("D:/COURSES/Artificial Intellegence Engineer/Data Analytics With Python/Analyse the Federal Aviation Authority Dataset using Pandas/SUBMISSION/SOURCE CODE/faa_ai_prelim.csv")<jupyter_output><empty_output><jupyter_text>2: View and understand the dataset<jupyter_code>#View the dataset shape
df_faa_dataset.shape
#View the first five observations
df_faa_dataset.head()
#View all the columns present in the dataset
df_faa_dataset.columns<jupyter_output><empty_output><jupyter_text>3: Extract the following attributes from the dataset:1. Aircraft make name2. State name3. Aircraft model name4. Text information5. Flight phase6. Event description type7. Fatal flag<jupyter_code>#Create a new dataframe with only the required columns
df_analyze_dataset = df_faa_dataset[['LOC_STATE_NAME', 'RMK_TEXT', 'EVENT_TYPE_DESC', 'ACFT_MAKE_NAME',
                                     'ACFT_MODEL_NAME', 'FLT_PHASE', 'FATAL_FLAG']]
#View the type of the object
type(df_analyze_dataset)
#Check if the dataframe contains all the required attributes
df_analyze_dataset.head()<jupyter_output><empty_output><jupyter_text>4. Clean the dataset and replace the fatal flag NaN with “No”<jupyter_code>#Replace all Fatal Flag missing values with the required output
df_analyze_dataset['FATAL_FLAG'].fillna(value="No",inplace=True)
#Verify if the missing values are replaced
df_analyze_dataset.head()
#Check the number of observations
df_analyze_dataset.shape<jupyter_output><empty_output><jupyter_text>5. Remove all the observations where aircraft names are not available<jupyter_code>#Drop the unwanted values/observations from the dataset
df_final_dataset = df_analyze_dataset.dropna(subset=['ACFT_MAKE_NAME'])<jupyter_output><empty_output><jupyter_text>6. Find the aircraft types and their occurrences in the dataset<jupyter_code>#Check the number of observations now to compare it with the original dataset and see how many values have been dropped
df_final_dataset.shape
#Group the dataset by aircraft name
aircraftType = df_final_dataset.groupby('ACFT_MAKE_NAME')
#View the number of times each aircraft type appears in the dataset (Hint: use the size() method)
aircraftType.size()<jupyter_output><empty_output><jupyter_text>7: Display the observations where fatal flag is “Yes”<jupyter_code>#Group the dataset by fatal flag
fatalAccedents = df_final_dataset.groupby('FATAL_FLAG')
#View the total number of fatal and non-fatal accidents
fatalAccedents.size()
#Create a new dataframe to view only the fatal accidents (Fatal Flag values = Yes)
accidents_with_fatality = fatalAccedents.get_group('Yes')
accidents_with_fatality.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07098955132145052, 'fraction_numerical': 0.004917025199754148, 'mean_word_length': 6.713270142180095, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '65049', 'license': 'MIT', 'n_tokens_mistral': 983, 'n_tokens_neox': 950, 'n_words': 333, 'path': 'Analyse the Federal Aviation Authority Dataset using Pandas/SUBMISSION/SOURCE CODE/Pandas - Assignment 01.ipynb', 'repo_name': 'NeoWist/aiengineer-simplylearn-projects', 'size': '3254'}