Question: Loop over DataFrame ( 2 ) The row data that's generated by iterrows ( ) on every run is a Pandas Series. This format is
Loop over DataFrame
The row data that's generated by iterrows on every run is a Pandas Series. This format is not very convenient to print out. Luckily, you can easily select variables from the Pandas Series using square brackets:
for lab, row in brics.iterrows :
printrowcountry
Instructions
XP
Using the iterators lab and row, adapt the code in the for loop such that the first iteration prints out US: the second iteration "AUS: and so on
The output should be in the form "country: carspercap". Make sure to print out this exact string with the correct spacing
You can use str to convert your integer data to a string so that you can print it in conjunction with the country label.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
