API Overview¶
This page helps you choose the right function or class for your task, explains the main components, and shows common usage patterns.
On this page
Decision Guide¶
What do you want to do?
│
├─ Get data for ONE element
│ └─> Use element('Symbol')
│
├─ Get data for MANY elements
│ └─> Use fetch_table('elements')
│
├─ Get isotope data
│ ├─ For one isotope
│ │ └─> Use isotope('Symbol', mass_number)
│ └─ For all isotopes of element
│ └─> Use element('Symbol').isotopes
│
├─ Work with ions
│ └─> Use Ion('Symbol', charge=N)
│
├─ Create visualizations
│ └─> Use periodic_table(...)
│
├─ Compare electronegativity scales
│ └─> Use fetch_electronegativities([scales])
│
└─ Direct database queries
└─> Use get_session() (advanced)
Quick Reference¶
Most Common Functions¶
Function |
Purpose |
Returns |
|---|---|---|
|
Get element by symbol/name/number |
Element |
|
Get database table as DataFrame |
DataFrame |
|
Get specific isotope |
Isotope |
|
Create visualization |
Plot/Figure |
|
Create ionic species |
Ion |
Most Useful Element Properties¶
Property |
Description |
Unit |
Example |
|---|---|---|---|
|
Atomic number |
— |
|
|
Atomic weight |
Da |
|
|
Atomic radius (Slater) |
pm |
|
|
Pauling electronegativity |
— |
|
|
Electron affinity |
eV |
|
|
Ionization energies |
eV |
|
|
Melting point |
K |
|
|
Boiling point |
K |
|
|
Density at 295K |
g/cm³ |
|
|
List of isotopes |
— |
|
Available Database Tables¶
Table Name |
Contents |
|---|---|
|
All element data (main table) |
|
Isotope data with masses, abundances, half-lives |
|
Ionic radii for various oxidation states |
|
Successive ionization energies |
|
Possible oxidation states |
|
Nuclear screening constants |
|
Periodic table group information |
|
Element series (alkali metals, noble gases, etc.) |
|
Metadata about properties (units, sources, citations) |
|
Isotope decay modes and branching ratios |
|
Phase transition data |
|
X-ray and neutron scattering factors |
Architecture¶
The mendeleev package is organized into several layers:
User-Facing API
├── Element Access (element, isotope)
├── Bulk Data (fetch_table, fetch_*)
└── Visualization (periodic_table)
│
Data Models
├── Element, Isotope, Ion
├── IonicRadius, IonizationEnergy
└── Other property classes
│
Database Layer
└── SQLite database (elements.db)
Main Components¶
1. Element Access Functions¶
High-level functions for accessing individual elements and isotopes.
elementPrimary function for getting element data by symbol, name, or atomic number. Use this for most element access needs.
isotopeGet specific isotope data by element and mass number.
get_all_elementsGet a list of all elements. Note: For data analysis, use
fetch_tableinstead.
Example:
from mendeleev import element
# Get silicon by symbol
si = element('Si')
print(si.atomic_radius) # 132
# Get multiple elements
c, h, o = element(['C', 'H', 'O'])
2. Data Fetching Functions¶
Functions for bulk data access, returning pandas DataFrames.
fetch_tableFetch any database table as a DataFrame. Most versatile bulk access function. Available tables:
elements,isotopes,ionicradii,ionizationenergies,oxidationstates,screeningconstants,series,groups,propertymetadata.fetch_electronegativitiesGet electronegativity data across multiple scales.
fetch_ionization_energiesGet ionization energy data for specific degrees.
fetch_ionic_radiiGet ionic radii data with different radius types.
Example:
from mendeleev import fetch_table
# Get all elements as DataFrame
elements = fetch_table('elements')
# Filter and analyze
noble_gases = elements[elements['group_id'] == 18]
print(noble_gases[['symbol', 'name', 'boiling_point']])
3. Data Models¶
Object-oriented representations of chemical entities and properties.
Core Models:
ElementThe main element class with 80+ properties and methods. Access via
element().IsotopeIsotope data including mass, abundance, half-life, and decay modes. Access via
isotope()orelement.isotopes.IonIonic species with charge-dependent properties. Create with
Ion('Fe', charge=2).
Property Models:
IonicRadiusIonic radii for different oxidation states and coordination numbers.
IonizationEnergySuccessive ionization energies.
OxidationStatePossible oxidation states for elements.
PropertyMetadataMetadata about properties including units, sources, and citations.
4. Visualization Functions¶
Functions for creating interactive periodic table visualizations.
periodic_tableMain function for creating customizable periodic tables. Supports multiple backends: bokeh, plotly, seaborn.
Backends:
mendeleev.vis.bokeh- Interactive Bokeh visualizationsmendeleev.vis.plotly- Interactive Plotly visualizationsmendeleev.vis.seaborn- Static matplotlib/seaborn visualizations
Example:
from mendeleev.vis import periodic_table
# Create interactive periodic table colored by property
periodic_table(colorby='atomic_radius', backend='plotly')
5. Electronegativity Functions¶
Functions for computing various electronegativity scales.
mendeleev.electronegativityModule containing functions for 15+ electronegativity scales:
Stored scales: Access via
element.en_pauling,element.en_allen, etc.Computed scales: Functions like
mulliken(),sanderson(), etc.
See Electronegativities for detailed scale descriptions.
6. Database Functions¶
Low-level database access (advanced users).
get_sessionGet SQLAlchemy session for direct database queries.
get_engineGet SQLAlchemy engine.
Note: Most users should use element()
or fetch_table() instead.
Common Usage Patterns¶
The Quick Start guide provides copy-paste examples for common tasks. This section summarizes which function to use for each use case.
Use case |
Function |
See also |
|---|---|---|
Get properties for one element |
|
|
Bulk data across all elements |
|
|
Isotope data |
|
|
Ion properties |
|
|
Periodic table plots |
|
|
Electronegativity comparison |
|
|
Property metadata lookup |
|
Type Hints¶
The mendeleev API uses type hints extensively. Here are the main types:
from typing import Union, List
from mendeleev.models import Element, Isotope
from mendeleev.ion import Ion
import pandas as pd
# Element access
element(ids: Union[int, str]) -> Element
element(ids: Union[List, Tuple]) -> List[Element]
# Isotope access
isotope(symbol_or_atn: Union[str, int], mass_number: int) -> Isotope
# Bulk data
fetch_table(table: str) -> pd.DataFrame
# Ions
Ion(label: Union[str, int], charge: int) -> Ion
Error Handling¶
Common exceptions and how to handle them:
ValueError: Element not found
from mendeleev import element
try:
el = element('Unobtanium')
except ValueError as e:
print(f"Element not found: {e}")
ValueError: Invalid charge for ion
from mendeleev.ion import Ion
try:
# Charge too large
ion = Ion('H', charge=5)
except ValueError as e:
print(f"Invalid charge: {e}")
NoResultFound: Isotope not found
from mendeleev import isotope
from sqlalchemy.exc import NoResultFound
try:
# Non-existent isotope
iso = isotope('C', 999)
except NoResultFound:
print("Isotope not found")
See Also¶
Accessing data - Detailed guide on accessing data
Data - Complete property reference
Tutorials - Step-by-step tutorials
API Reference - Complete API reference
Troubleshooting - Common issues and solutions
Next Steps¶
New Users: Start with the quick start guide and tutorials.
Data Analysis: Learn about bulk data access.
Visualization: Explore visualization tutorials.
Advanced: Read the full API Reference.