Hello, everyone
Here is the first of the Portfolio Projects.
It was a while since I re-engage with the Data Science path, and I needed to review all the changes/improvements.
I only use the CSV library to obtain the answers and limit myself not to use any other graphical aid as I believe this will come later in the journey.
The project took me 1 day to complete. It was not that hard, and following the HINTs, help you a lot.
I’m leaving the link to my code in case you can provide me some feedback.
Access To my project
Best regards,
Rodolfo Mares
Welcome back to the forums!
Looks good! Seems like you have a proficient understanding of how to navigate around the data and creating functions.
-
I think it’s beneficial that you have inserted text cells that explain what your thought processes are as you write and execute your code. (It helps the reader/viewer gain a better understanding).
-
If you wanted to limit the number of rows you print out with with
I think you can limit them by creating a loop and then using break
. Like this (suggestion 2).
It’s just an idea b/c that’s a fairly large data set.
(Also, as you go along, you’ll see how you can do that with Pandas quite easily.)
-
If you wanted to round the charges to two decimal places you could look into using the round()
function too. See here.
Happy coding!
Hello, Lisa
Thank you so much for your comments.
Can you please share one more time the limit suggestion using CSV? For some reason, the link didn’t work for me.
Regards,
Oh, jeez! Sorry about that non-working link. Now I don’t recall what it was. I think it was on stack overflow.
Try this instead. You can create a reader object and use a loop to iterate over the rows and limit the number of rows to say, 5 or 10. Something a bit more manageable than hundreds in a notebook cell.
Your code:
import csv
with open("insurance.csv") as insurance:
print(insurance.read())
updated if you want to limit the rows…
import csv
with open("insurance.csv") as insurance:
reader = csv.reader(insurance, delimeter=','):
count = 0
for row in reader:
print(row)
if count > 10:
break
count += 1
It’s just a thought! 
Wait until you get to Pandas! It’s pretty cool. 
Thank you so much, Lisa
I will incorporate the change to my code to limit the rows for a quick review.
I’m familiar with Pandas. It’s really cool and powerful; however, I wanted to use the plain CSV capabilities that Python offers on this project. I could not exploit the CSV capabilities until this recent update of the Data Scientist Path.
1 Like