Accessing data

Individual Elements

The easiest way to access individual elements is simply by importing them from the mendeleev directly using their symbols:

>>> from mendeleev import H, C, O, Og
>>> [x.name for x in [H, C, O, Og]]
['Hydrogen', 'Carbon', 'Oxygen', 'Oganesson']

An alternative method of access is through the element() function that returns either a single Element instance or a tuple of those instances depending on the input. It provides a more flexible interface since it accepts element names, atomic numbers and symbols as well as their combinations.

Fetching data in bulk

If you want a whole set of data you can retrieve one of the tables from the database as pandas DataFrame through the fetch_table(). The following tables are available:

fetch_table(table: str, **kwargs) pandas.DataFrame[source]

Return a table from the database as pandas.DataFrame

Parameters:
  • table – Name of the table from the database

  • kwargs – A dictionary of keyword arguments to pass to the pandas.read_qsl()

Returns:

Pandas DataFrame with the contents of the table

Return type:

df (pandas.DataFrame)

Example

>>> from mendeleev.fetch import fetch_table
>>> df = fetch_table('elements')
>>> type(df)
pandas.core.frame.DataFrame
fetch_ionization_energies(degree: List[int] | int = 1) pandas.DataFrame[source]

Fetch a pandas.DataFrame with ionization energies for all elements indexed by atomic number.

Parameters:

degree – Degree of ionization, either as int or a list of ints. If a list is passed then the output will contain ionization energies corresponding to particalr degrees in columns.

Returns:

ionization energies, indexed by atomic number

Return type:

df (pandas.DataFrame)

fetch_ionic_radii(radius: str = 'ionic_radius') pandas.DataFrame[source]

Fetch a pandas DataFrame with ionic radii for all the elements.

Parameters:

radius – The radius to be returned either ionic_radius or crystal_radius

Returns:

a table with atomic numbers, symbols and ionic radii for all

coordination numbers

Return type:

df (pandas.DataFrame)

Computed properties

Some properties need to be computed rather than directly retrieved from the database. Electronegativities

fetch_electronegativities(scales: List[str] = None) pandas.DataFrame[source]

Fetch electronegativity scales for all elements as pandas.DataFrame

Parameters:

scales – list of scale names, defaults to all available scales

Returns:

Pandas DataFrame with the contents of the table

Return type:

df (pandas.DataFrame)

Database session and engine

For those how want to interact with the database through a layer of SQLAlchemy there are methods for getting the session or the engine:

get_session(dbpath: str = None) Session[source]

Return the database session connection.

get_engine(dbpath: str = None) Engine[source]

Return the db engine