Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
In units of the Earth, the density of a planet is its mass divided by the cube of its radius. Use the table of the planets with the columns name, kind, mass (0.055, 0.815, 1.0, 0.107, 317.8, 95.2, 14.5, 17.1) and radius (0.38, 0.95, 1.0, 0.53, 11.2, 9.45, 4.01, 3.88). Add a column density, find the planet with the lowest density, and the mean density of each kind.
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. The new column is a formula on whole columns. idxmin gives the row of the smallest density. groupby("kind") gives the mean of each kind.
Check. The Earth has the density 1 by definition. Saturn has , the lowest: less than the density of water (about 0.18 of the Earth's), so it would float. The mean density of the rocky planets is 0.918 and of the giants 0.214.
Answer: Saturn has the lowest density, 0.113 (in Earth densities). The mean density is 0.918 for the rocky planets and 0.214 for the giants.
Log in to join the discussion.
Loading…