Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Make a table of the four rocky planets with the columns name, distance_au (0.39, 0.72, 1.00, 1.52) and period_years (0.24, 0.62, 1.00, 1.88). Print its shape, the names of its columns, the mean period, and the name of the planet with the longest period.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Make the table from a dictionary of lists. The name of the planet with the longest period is found with idxmax, which gives the label (the row) of the largest value, and then loc.
Check. There are 4 rows and 3 columns. The mean of the periods is years. The longest period is 1.88 years, and it belongs to Mars.
Answer: (4, 3), the columns name, distance_au and period_years, the mean 0.935, and Mars.
Log in to join the discussion.
Loading…