Tell us what’s happening:
When should you use loc?
My question specifically revolves around:
“# What is the minimum number of hours a person works per week (hours-per-week feature)?”
If I say:
min_work_hours = df[‘hours-per-week’].min()
then I get a valid minimum
If I say:
min_work_hours = df.loc[‘hours-per-week’].min()
then I get a KeyError.
I thought that option 2 was simply stating the same thing as option 1, but explicitly.
Can someone explain when I should be using option 1 vs option 2?
Your code so far
Challenge: Data Analysis with Python Projects - Demographic Data Analyzer
Link to the challenge: