pandas_ext

Pandas DataFrame Accessor

The chem accessor provides chemistry-aware operations on Pandas DataFrames and Series containing molecule columns. CNotebook also treats OEPandas QueryDtype columns as depictable query molecule columns.

Usage

import cnotebook
import pandas as pd
import oepandas as oepd

# The accessor is automatically registered when cnotebook is imported
df = pd.DataFrame({"SMILES": ["CCO", "c1ccccc1"]})

# Convert SMILES to molecules
df.chem.as_molecule("SMILES", inplace=True)

# Query columns render with the same formatter
queries = pd.DataFrame({"Query": ["[#6]-[#8]"]})
queries.chem.as_query("Query", inplace=True)

# Highlight substructures
df.SMILES.chem.highlight("c1ccccc1")

# Align depictions
df.SMILES.chem.align_depictions("first")

# Create MolGrid
grid = df.SMILES.chem.molgrid()

DataFrame Methods

DataFrame.chem.as_molecule(column, inplace=False)

Convert a SMILES column to molecules.

DataFrame.chem.highlight_using_column(mol_col, pattern_col, inplace=False)

Highlight substructures using patterns from another column.

DataFrame.chem.fingerprint_similarity(mol_col, reference, inplace=False)

Color molecules by fingerprint similarity to a reference.

DataFrame.chem.molgrid(**kwargs)

Create a MolGrid from the DataFrame.

DataFrame.chem.set_render_options(molecule_columns=None, **kwargs)

Set CNotebook rendering options for molecule or query columns.

Series Methods

Series.chem.highlight(smarts)

Highlight a SMARTS pattern in the molecule column.

Series.chem.align_depictions(reference)

Align molecule depictions to a reference.

Series.chem.set_render_options(**kwargs)

Set CNotebook rendering options for a molecule or query Series.

Series.chem.molgrid(**kwargs)

Create a MolGrid from the Series.