tables_io.conv.conv_tabledict

Multi-Table Convert Functions for tables_io

Functions

convert(obj, tType)

Converts Table-like or TableDict-like objects to a specific tabular format.

convert_to_ap_tables(→ Mapping)

Convert several objects to astropy.table.Table

convert_to_dicts(→ Mapping)

Convert several objects to OrderedDict, (str, numpy.array)

convert_to_recarrays(→ Mapping)

Convert several objects to np.recarray

convert_to_pa_tables(→ Mapping)

Convert several objects to pa.Table

convert_to_dataframes(→ Mapping)

Convert several objects to pandas.DataFrame

convert_to_json_strings(→ Mapping)

Convert several objects to json str

Module Contents

convert(obj, tType: str | int)[source]

Converts Table-like or TableDict-like objects to a specific tabular format. The given table format type must be one of the supported types listed below.

If given a TableDict-like object, each of the Table-like objects in it are converted to the desired format. convert_obj is used to convert the Table-like objects.

Accepted table formats:

Format string

Format integer

“astropyTable”

0

“numpyDict”

1

“numpyRecarray”

2

“pandasDataFrame”

3

“pyarrowTable”

4

“jsonString”

5

Parameters:
  • obj (‘Table-like` or TableDict-like) – The input object.

  • tType (int or str) – The table format to convert to.

Returns:

out – The converted data.

Return type:

Table-like or TableDict-like

Example

Converting a Table-like object, in this case an astropy.table.Table object, to a pyarrow.Table object:

>>> import tables_io
>>> from astropy.table import Table
>>> tab = Table([[1,2], [3,4]],names=('x','y'))
>>> tables_io.convert(tab,'pyarrowTable')
pyarrow.Table
x: int64
y: int64
----
x: [[1,2]]
y: [[3,4]]
convert_to_ap_tables(odict: Mapping) Mapping[source]

Convert several objects to astropy.table.Table

Parameters:

odict (Mapping, (str, Table-like)) – The input objects

Returns:

tabs – The tables

Return type:

OrderedDict of astropy.table.Table

convert_to_dicts(odict: Mapping) Mapping[source]

Convert several objects to OrderedDict, (str, numpy.array)

Parameters:

odict (Mapping, (str, Table-like)) – The input objects

Returns:

tabs – The tables

Return type:

OrderedDict of OrderedDict, (str, numpy.array)

convert_to_recarrays(odict: Mapping) Mapping[source]

Convert several objects to np.recarray

Parameters:

odict (Mapping, (str, Table-like)) – The input objects

Returns:

tabs – The tables

Return type:

OrderedDict of np.recarray

convert_to_pa_tables(odict: Mapping) Mapping[source]

Convert several objects to pa.Table

Parameters:

odict (Mapping, (str, Table-like)) – The input objects

Returns:

tabs – The tables

Return type:

OrderedDict of np.recarray

convert_to_dataframes(odict: Mapping) Mapping[source]

Convert several objects to pandas.DataFrame

Parameters:

odict (Mapping, (str, Table-like)) – The input objects

Returns:

df – The dataframes

Return type:

OrderedDict of pandas.DataFrame

convert_to_json_strings(odict: Mapping) Mapping[source]

Convert several objects to json str

Parameters:

odict (Mapping, (str, Table-like)) – The input objects

Returns:

df – The json strings

Return type:

OrderedDict of str