Skip to content

Instantly share code, notes, and snippets.

@ddofer
Last active April 22, 2020 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddofer/59d0f583823096b878b01d9c05822ff2 to your computer and use it in GitHub Desktop.
Save ddofer/59d0f583823096b878b01d9c05822ff2 to your computer and use it in GitHub Desktop.
Get list of chemical elements from Wikipedia + Pandas
import pandas as pd
# read wikipedia html table with info on all elemetns, including symbols, names, properties:
df_base = pd.read_html("https://en.wikipedia.org/wiki/List_of_chemical_elements")[0]
element_full_names = df_base["List of chemical elements"]["Element"][:-1] # last row is comments
element_full_names =list(element_full_names.apply(lambda x: x[0],axis=1).values) # get individual names out of wrapped list format
# element_full_names.to_csv("names_of_elements.csv",index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment