File: pandas.rst

package info (click to toggle)
python-pubchempy 1.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 388 kB
  • sloc: python: 1,377; makefile: 147
file content (29 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.. _pandas:

*pandas* integration
====================

Getting *pandas*
----------------

*pandas* must be installed to use its functionality from within PubChemPy. The easiest way is to use pip::

    pip install pandas

See the `pandas documentation`_ for more information.

Usage
-----

It is possible for ``get_compounds``, ``get_substances`` and ``get_properties`` to return a pandas DataFrame::

    df1 = pcp.get_compounds('C20H41Br', 'formula', as_dataframe=True)
    df2 = pcp.get_substances([1, 2, 3, 4], as_dataframe=True)
    df3 = pcp.get_properties(['isomeric_smiles', 'xlogp', 'rotatable_bond_count'], 'C20H41Br', 'formula', as_dataframe=True)

An existing list of Compound objects can be converted into a dataframe, optionally specifying the desired columns::

    cs = pcp.get_compounds('C20H41Br', 'formula')
    df4 = pcp.compounds_to_frame(cs, properties=['isomeric_smiles', 'xlogp', 'rotatable_bond_count'])

.. _`pandas documentation`: http://pandas.pydata.org/pandas-docs/stable/