Recall Loops
Imagine that you want to count how many 'Data Scientist' jobs are in the dataset. You are already familiar with the loops and if/else statements. Try it.
Swipe to start coding
Follow the algorithm:
- Create a
forloop that iterates through the'job_title'column in thedf. - Within the
forloop, implement theifstatement that checks ifiis equal to'Data Scientist'. - Within the
ifstatement, increase thecountvariable by 1.
Lösning
In this chapter, you count values in a straightforward but irrational way. Imagine that you have thousands of rows in the dataset; such a loop may take even an hour to process, depending on the dataset's size and the computer's power. Thus, in the next section, you will learn how to do the same thing but in a way that
pandasoffer you.
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Sammanfatta detta kapitel
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 2.08
Recall Loops
Svep för att visa menyn
Imagine that you want to count how many 'Data Scientist' jobs are in the dataset. You are already familiar with the loops and if/else statements. Try it.
Swipe to start coding
Follow the algorithm:
- Create a
forloop that iterates through the'job_title'column in thedf. - Within the
forloop, implement theifstatement that checks ifiis equal to'Data Scientist'. - Within the
ifstatement, increase thecountvariable by 1.
Lösning
In this chapter, you count values in a straightforward but irrational way. Imagine that you have thousands of rows in the dataset; such a loop may take even an hour to process, depending on the dataset's size and the computer's power. Thus, in the next section, you will learn how to do the same thing but in a way that
pandasoffer you.
Tack för dina kommentarer!
single