0% found this document useful (0 votes)
6 views26 pages

Automobile Data Analysis with Pandas

Uploaded by

anuragsingh0406
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views26 pages

Automobile Data Analysis with Pandas

Uploaded by

anuragsingh0406
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import pandas as pd

import [Link] as plt


import seaborn as sns

df=pd.read_csv("[Link]")

[Link]()

Age Gender Profession Marital_status Education


No_of_Dependents \
0 53 Male Business Married Post Graduate
4
1 53 Femal Salaried Married Post Graduate
4
2 53 Female Salaried Married Post Graduate
3
3 53 Female Salaried Married Graduate
2
4 53 Male Salaried Married Post Graduate
3

Personal_loan House_loan Partner_working Salary Partner_salary \


0 No No Yes 99300 70700.0
1 Yes No Yes 95500 70300.0
2 No No Yes 97300 60700.0
3 Yes No Yes 72500 70300.0
4 No No Yes 79700 60200.0

Total_salary Price Make


0 170000 61000 SUV
1 165800 61000 SUV
2 158000 57000 SUV
3 142800 61000 SUV
4 139900 57000 SUV

[Link]()

<class '[Link]'>
RangeIndex: 1581 entries, 0 to 1580
Data columns (total 14 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Age 1581 non-null int64
1 Gender 1528 non-null object
2 Profession 1581 non-null object
3 Marital_status 1581 non-null object
4 Education 1581 non-null object
5 No_of_Dependents 1581 non-null int64
6 Personal_loan 1581 non-null object
7 House_loan 1581 non-null object
8 Partner_working 1581 non-null object
9 Salary 1581 non-null int64
10 Partner_salary 1475 non-null float64
11 Total_salary 1581 non-null int64
12 Price 1581 non-null int64
13 Make 1581 non-null object
dtypes: float64(1), int64(5), object(8)
memory usage: 173.1+ KB

[Link]().sum()

Age 0
Gender 53
Profession 0
Marital_status 0
Education 0
No_of_Dependents 0
Personal_loan 0
House_loan 0
Partner_working 0
Salary 0
Partner_salary 106
Total_salary 0
Price 0
Make 0
dtype: int64

[Link](
)

0 False
1 False
2 False
3 False
4 False
...
1576 False
1577 False
1578 False
1579 False
1580 False
Length: 1581, dtype: bool

df['Gender'].fillna(df['Gender'].mode()[0], inplace=True)

df['Gender'].unique()

array(['Male', 'Femal', 'Female', 'Femle'], dtype=object)

df['Partner_salary']=df['Total_salary']-df['Salary']

[Link]().sum()
Age 0
Gender 0
Profession 0
Marital_status 0
Education 0
No_of_Dependents 0
Personal_loan 0
House_loan 0
Partner_working 0
Salary 0
Partner_salary 0
Total_salary 0
Price 0
Make 0
dtype: int64

df['Gender']=df['Gender'].replace({'Femal':'Female','Femle':'Female'})

df['Gender'].unique()

array(['Male', 'Female'], dtype=object)

print(df['Gender'].value_counts())

Gender
Male 1252
Female 329
Name: count, dtype: int64

[Link]()

Age No_of_Dependents Salary Partner_salary \


count 1581.000000 1581.000000 1581.000000 1581.000000
mean 31.922201 2.457938 60392.220114 19233.776091
std 8.425978 0.943483 14674.825044 19670.391171
min 22.000000 0.000000 30000.000000 0.000000
25% 25.000000 2.000000 51900.000000 0.000000
50% 29.000000 2.000000 59500.000000 25100.000000
75% 38.000000 3.000000 71800.000000 38100.000000
max 54.000000 4.000000 99300.000000 80500.000000

Total_salary Price
count 1581.000000 1581.000000
mean 79625.996205 35597.722960
std 25545.857768 13633.636545
min 30000.000000 18000.000000
25% 60500.000000 25000.000000
50% 78000.000000 31000.000000
75% 95900.000000 47000.000000
max 171000.000000 70000.000000
[Link]()

Age Gender Profession Marital_status Education


No_of_Dependents \
0 53 Male Business Married Post Graduate
4
1 53 Female Salaried Married Post Graduate
4
2 53 Female Salaried Married Post Graduate
3
3 53 Female Salaried Married Graduate
2
4 53 Male Salaried Married Post Graduate
3

Personal_loan House_loan Partner_working Salary Partner_salary \


0 No No Yes 99300 70700
1 Yes No Yes 95500 70300
2 No No Yes 97300 60700
3 Yes No Yes 72500 70300
4 No No Yes 79700 60200

Total_salary Price Make


0 170000 61000 SUV
1 165800 61000 SUV
2 158000 57000 SUV
3 142800 61000 SUV
4 139900 57000 SUV

[Link]()

Age Gender Profession Marital_status Education No_of_Dependents


\
1576 22 Male Salaried Single Graduate 2

1577 22 Male Business Married Graduate 4

1578 22 Male Business Single Graduate 2

1579 22 Male Business Married Graduate 3

1580 22 Male Salaried Married Graduate 4

Personal_loan House_loan Partner_working Salary Partner_salary


\
1576 No Yes No 33300 0

1577 No No No 32000 0

1578 No Yes No 32900 0


1579 Yes Yes No 32200 0

1580 No No No 31600 0

Total_salary Price Make


1576 33300 27000 Hatchback
1577 32000 31000 Hatchback
1578 32900 30000 Hatchback
1579 32200 24000 Hatchback
1580 31600 31000 Hatchback

[Link](data=df,x='Gender',hue='Gender');
[Link]('Bar chat-Gender')
[Link]('Gender')
[Link]('Count')
[Link]()

[Link](data=df,x='Profession',hue='Profession');
[Link]('Bar chat-Profession')
[Link]('Profession')
[Link]('Count')
[Link]()

[Link](data=df,x='Marital_status',hue='Marital_status');
[Link]('Bar chat-Marital_status')
[Link]('Marital_status')
[Link]('Count')
[Link]()
[Link](data=df,x='Education',hue='Education');
[Link]('Bar chat-Education')
[Link]('Education')
[Link]('Count')
[Link]()
[Link](data=df,x='Personal_loan',hue='Personal_loan',);
[Link]('Bar chat-Personal_loan')
[Link]('Personal_loan')
[Link]('Count')
[Link]()
df['Personal_loan'].value_counts(normalize=True) * 100

Personal_loan
Yes 50.094877
No 49.905123
Name: proportion, dtype: float64

[Link](data=df,x='House_loan',hue='House_loan',);
[Link]('Bar chat-House_loan')
[Link]('House_loan')
[Link]('Count')
[Link]()
df['House_loan'].value_counts(normalize=True) * 100

House_loan
No 66.666667
Yes 33.333333
Name: proportion, dtype: float64

[Link](data=df,x='Partner_working',hue='Partner_working',);
[Link]('Bar chat-Partner_working')
[Link]('Partner_working')
[Link]('Count')
[Link]()
[Link](data=df,x='Make',hue='Make',);
[Link]('Bar chat-Vehicle_type')
[Link]('Vehicle_type')
[Link]('Count')
[Link]()
[Link](data=df, x='Age', kde=True);
[Link]('Histogram-Age')
[Link]('Age')
[Link]('Count')
[Link]()
df['Age'].describe()

count 1581.000000
mean 31.922201
std 8.425978
min 22.000000
25% 25.000000
50% 29.000000
75% 38.000000
max 54.000000
Name: Age, dtype: float64

[Link](data=df, x='Salary', kde=True);


[Link]('Histogram-Salary')
[Link]('Salary')
[Link]('Count')
[Link]()
[Link](data=df, x='Partner_salary', kde=True);
[Link]('Histogram-Partner_salary')
[Link]('Partner_salary')
[Link]('Count')
[Link]()
[Link](data=df, x='Total_salary', kde=True);
[Link]('Histogram-Total_salary')
[Link]('Total_salary')
[Link]('Count')
[Link]()
[Link](data=df, x='Price', kde=True);
[Link]('Histogram-Price')
[Link]('Price')
[Link]('Count')
[Link]()
[Link](data=df);
selected_cols = ['Age', 'No_of_Dependents', 'Salary',
'Partner_salary', 'Total_salary', 'Price']
df_selected = df[selected_cols]
correlation_table = df_selected.corr()
print(correlation_table)

Age No_of_Dependents Salary Partner_salary


\
Age 1.000000 -0.189614 0.616899 0.135702

No_of_Dependents -0.189614 1.000000 -0.031746 0.144320


Salary 0.616899 -0.031746 1.000000 0.087155

Partner_salary 0.135702 0.144320 0.087155 1.000000

Total_salary 0.458869 0.092890 0.641560 0.820069

Price 0.797831 -0.135839 0.409920 0.171875

Total_salary Price
Age 0.458869 0.797831
No_of_Dependents 0.092890 -0.135839
Salary 0.641560 0.409920
Partner_salary 0.820069 0.171875
Total_salary 1.000000 0.367823
Price 0.367823 1.000000

[Link](data=correlation_table, annot=True, cmap='coolwarm',


fmt='.2f');
[Link]('Correlation Heatmap')
[Link]()
[Link](data=df,x='Gender',hue='Make');
[Link]('Bar chat-Gender')
[Link]('Gender')
[Link]('Count')
[Link]()
[Link](data=df,x='Profession',hue='Make');
[Link]('Bar chat-Gender')
[Link]('Profession')
[Link]('Count')
[Link]()
df['Profession_Gender'] = df['Profession'] + '_' + df['Gender']
[Link](data=df, x='Profession_Gender', hue='Make')
[Link]('Bar chart - Profession and Gender')
[Link]('Profession and Gender')
[Link]('Count')
[Link]()
[Link](data=df, x='Gender', y='Price');
[Link]('Toatl amount spent on vechiles by Gender ')
[Link]('Gender')
[Link]('Price')
[Link]()
[Link](data=df, x='Personal_loan', y='Price');
[Link]('Toatl amount spent on vechiles- by Perseonal Loan ')
[Link]('Personal_loan')
[Link]('Price')
[Link]()
[Link](data=df, x='Partner_working', y='Price');
[Link]('Influence of Partner woking om purchase of High-priced
cars')
[Link]('Partner_working')
[Link]('Price')
[Link]()

Common questions

Powered by AI

The correlation between 'Age' and 'Salary' is 0.616899, while the correlation between 'Age' and 'Price' is 0.797831 . This suggests a stronger positive relationship between 'Age' and 'Price' compared to 'Age' and 'Salary'. It may indicate that older individuals tend to spend more on vehicles, possibly due to higher financial stability or different vehicle preferences that come with age.

The bar chart and visualization data suggest a potential demographic influence on the type of vehicles purchased . For instance, trends may show that SUVs are more popular among certain professions or age groups, reflecting lifestyle preferences or income levels. Hatchbacks might be preferred by younger or single individuals due to affordability. This implies that demographic factors such as age, profession, or marital status can significantly dictate vehicle preferences.

The correlation table indicates a high correlation between 'Total_salary' and 'Salary' (0.641560) as well as 'Total_salary' and 'Partner_salary' (0.820069). This suggests that both individual salary and partner salary significantly contribute to total household earnings, which may directly impact financial decision-making. A higher combined income could lead to greater disposable income, influencing decisions like larger purchases, savings, or investments.

The boxplot visualization indicates that whether a partner is working or not might affect the price of the car purchased, possibly due to combined household income effects . Unlike factors such as personal loans or individual salary, the partner's working status might reflect a secondary income source contributing to household financial decisions. These factors may lead to different spending capacities and priorities, thus influencing car purchases in a distinct manner compared to individual-only metrics.

The dataset originally contained variations in the 'Gender' field, such as 'Femal' and 'Femle', which were corrected to 'Female' . Handling these inconsistencies reduces errors in data analysis by ensuring uniform data entries. If left uncorrected, these variations could lead to incorrect gender-based analysis results, as they might be falsely treated as separate categories during computations or visualizations.

Filling missing 'Gender' values with the mode means that all missing values are replaced with the most frequent 'Gender' category, which in this case is 'Male' . This approach can introduce bias, as it assumes 'Male' is representative of the missing data. It might skew any analysis related to gender distribution and its impact on other variables, reducing the accuracy of statistical conclusions or predictive models.

Approximately 50.1% of individuals have personal loans, while 33.3% have house loans . This suggests that personal loans are more common in the sample, indicating a higher propensity for individuals to incur debt for personal expenses or smaller asset acquisitions than for housing, possibly reflecting financial behaviors or priorities in the surveyed population.

Correcting the invalid entries 'Femal' and 'Femle' to 'Female' standardizes the dataset's 'Gender' field and prevents inaccuracies in counting or segregating data based on gender . This enhances the validity of gender studies by ensuring that all data are uniformly categorized, leading to more accurate comparative analyses and generalizations about gender-specific trends or behaviors.

The salary distribution, with a mean of 60,392 and a standard deviation of 14,674, indicates a spread of income levels within the group . This distribution allows an assessment of socio-economic disparities, highlighting potential inequalities or variations in purchasing power. Understanding income distribution aids in evaluating economic wellbeing, consumption capacity, and access to resources or opportunities for different subgroups within the population.

The absence of duplicated entries in the dataset implies good data quality and prevents redundant computations, ensuring that analyses and patterns are derived from unique data points . This increases the reliability of the analysis, as the conclusions are less likely to be distorted by the repetition of identical observations, leading to more accurate insights.

You might also like