A brief note on The Periodic Table as Data: the elements as a pandas table, selecting, sorting and filtering, computed columns, plots of the trends coloured by block, and groupby, corr and diff to find patterns and breaks. With a worked example, practice, a program and questions to check yourself.
A brief note on The Periodic Table as Data. Read it before a test. Try each question at the end before you open its answer.
pd.read_csv(io.StringIO(text), sep=" ", names=cols) turns typed text into a DataFrame. nan is a missing value.df["ie"] is a column; df[["symbol", "ie"]] is a smaller table; df.set_index("symbol").loc["Na", "ie"] is one value.df.sort_values("radius", ascending=False) sorts; store the result to keep it.df[condition]; join conditions with & or |, each in brackets.df["ie_eV"] = df["ie"] / 96.49, for every row at once.plt.plot(df["z"], df["ie"], "o-"); label each axis with its unit.plt.scatter(..., c=df["block"].map(colours)) colours points by block.df.groupby("block")["ie"].mean(): the mean of each block.df["radius"].corr(df["ie"]): from to ; here strongly negative.df.groupby("period")["ie"].diff(): the change from the element before, inside each period. A negative value is a break: boron and oxygen in period 2.What does this print?
It prints ['Al'].
The program finds the break in the rise across the p-block of period 4.
df["IE"] stops with KeyError: 'IE'.and between conditions. It stops with ValueError: The truth value of a Series is ambiguous; use & and brackets.notna() before plotting the radius.df["radius"].corr(df["ie"]) gives a value near . What does that mean in words?Log in to join the discussion.
Loading…