tables_io.conv.conv_tabledict
Multi-Table Convert Functions for tables_io
Functions
|
Converts Table-like or TableDict-like objects to a specific tabular format. |
|
Convert several objects to astropy.table.Table |
|
Convert several objects to OrderedDict, (str, numpy.array) |
|
Convert several objects to np.recarray |
|
Convert several objects to pa.Table |
|
Convert several objects to pandas.DataFrame |
|
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