1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Python for Data Science

Connected

Exercise

Dictionary to DataFrame (2)

The Python code that solves the previous exercise is included on the right. Have you noticed that the row labels (so the labels for the different observations) where automatically set to integers from 0 up to 6?

To solve this a list row_labels has been created. You can use it to specify the row labels of the cars DataFrame. You do this by setting the index attribute of cars, that you can access as cars.index.

Instructions

100 XP
  • Hit Submit Answer to see that, indeed, the row labels are not correctly set.
  • Specify the row labels by setting cars.index equal to row_labels.
  • Print out cars again and check if the row labels are correct this time.