Skip to content

Utilities

petropandas.pandas_accessors.PetroAccessor

Use .petro pandas dataframe accessor.

search(s, **kwargs)

Select subset of data from dataframe containing string s in index or column.

Note: Works only with non-numeric index or column

Parameters:

Name Type Description Default
s str

Returns all rows which contain string s in index or column.

required

Other Parameters:

Name Type Description
on str

Name of column used for search. When None the index is used

regex bool

If True, assumes the pat is a regular expression. If False, treats the pat as a literal string.

Returns:

Type Description
DataFrame

Dataframe with selected data

fix_columns(template)

Rename columns according to predefined template.

Check config['colnames'] for available templates. User-defined templates could be added. Template is a dict used for pandas.DataFrame.rename.

Parameters:

Name Type Description Default
template str

Name of renaming template

required

Returns:

Type Description
DataFrame

Dataframe with renamed columns

strip_columns()

Strip whitespaces from column names

Returns:

Type Description
DataFrame

Dataframe with stripped column names

calc(expr, name=None)

Calculate a new column using expression

Evaluate a string describing operations on DataFrame columns.

Parameters:

Name Type Description Default
expr str

The expression string to evaluate.

required
name str

Name of column to store result. When None the expression is used as name.

None

Returns:

Type Description
DataFrame

Dataframe with calculated column

to_latex(total=False, transpose=True, precision=2)

Convert datatable to LaTeX string

Parameters:

Name Type Description Default
total bool

Add column "Total" with total sums. Default True

False
transpose bool

Place samples as columns. Default True

True
precision bool

Nimber of decimal places. Default 2

2

petropandas.pandas_accessors.IsoplotAccessor

Use .isoplot pandas dataframe accessor.

df(**kwargs)

Returns dataframe.

Other Parameters:

Name Type Description
iso int

IsoplotR format. Default config["isoplot_default_format"]

C str

Column to be used as color. Default None

omit str

Column to be used as omit. Default None

comment str

Column to be used as comment. Default None

Returns:

Type Description
DataFrame

Dataframe

clipboard(**kwargs)

Copy data to clipbord to be used in IsoplotR online.

Note

IsoplotR online

Vermeesch, P., 2018, IsoplotR: a free and open toolbox for geochronology.
Geoscience Frontiers, v.9, p.1479-1493, doi: 10.1016/j.gsf.2018.04.001.

Other Parameters:

Name Type Description
iso int

IsoplotR format. Default config["isoplot_default_format"]

C str

Column to be used as color. Default None

omit str

Column to be used as omit. Default None

comment str

Column to be used as comment. Default None

calc_ages(**kwargs)

Copy data to clipbord, calc ages in IsoplotR online and paste back results.

Other Parameters:

Name Type Description
iso int

IsoplotR format. Default config["isoplot_default_format"]

C str

Column to be used as color. Default None

omit str

Column to be used as omit. Default None

comment str

Column to be used as comment. Default None

Returns:

Type Description
DataFrame | None

Dataframe with calculated ages