Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A table indexed by symbol is t = df.set_index("symbol"). Magnesium's first ionisation enthalpy is kJ/mol. What does t.loc["Mg", "ie"] give, and what kind of object does t.loc["Mg"] give?
A pandas DataFrame holds one element in each row. df[condition] keeps the rows where the condition is true; join conditions with &, each in brackets. sort_values("col", ascending=False) sorts from largest to smallest. set_index("symbol").loc[row, col] looks up one value. A computed column is one line, such as df["ie_eV"] = df["ie"] / 96.49.
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.
Step 1. Two labels. t.loc["Mg", "ie"] is the value in row Mg, column ie: .
Step 2. One label. t.loc["Mg"] is the whole row: a Series of z, group, period, block, radius, ie and en, labelled by column name.
Answer: kJ/mol; and a Series holding magnesium's whole row.
Log in to join the discussion.
Loading…