Hi everyone!
I finished Python Portfolio Project and now I’m seeking your review, dear pears!
It took me in general 2 days, I find the hardest pats is scoping. I’ve decided not to use classes, cause I find them quite excessive for this project, so I have used ordinary Python functions instead.
Here is the link to my repo:
Any ideas on how to improve the code or what else can be added to this analysis will be much appreciated.
Thanks in advance!
Congrats on completing the project! Seems like you have a solid grasp on how to navigate in the data and write functions to sort it all out.
Another way to get the stats on columns is by using the .describe()
method:
insurance['age'].describe()
count 1338.000000
mean 39.207025
std 14.049960
min 18.000000
25% 27.000000
50% 39.000000
75% 51.000000
max 64.000000
Name: age, dtype: float64
You could also use .value_counts()
to get the counts of values in a column:
insurance_regions = insurance['region'].value_counts()
print(insurance_regions)
southeast 364
northwest 325
southwest 325
northeast 324
Name: region, dtype: int64
And, if you wanted to break out the regions for comparison (or if you wanted to write a function to see if there’s any significance in the difference between the means, for example), you could use .iloc
:
ex:
southwest = insurance.iloc[(insurance['region']=='southwest').values]
southwest.head()
age sex bmi children smoker region charges
0 19 female 27.9 0 yes southwest 16884.924
12 23 male 34.4 0 no southwest 1826.843
15 19 male 24.6 1 no southwest 1837.237
18 56 male 40.3 0 no southwest 10602.385
19 30 male 35.3 0 yes southwest 36837.467
Just a suggestion. I think it’s good to know the various ways one can sift through the data.
Thank you a lot for paying attention to my project!
Your remarks are really valuable to me, I didn’t know about the methods you mentioned, but it seems really interesting and worth implementing to make the code neater.
1 Like
You’re welcome! I think it’s always good to know how to accomplish tasks in different ways. Personally, I’m always learning something new. 
1 Like