graviti.dataframe.column.series#

The implementation of the Graviti Series.

Module Contents#

Classes#

Series

One-dimensional array.

PyarrowSeries

Pyarrow based one-dimensional array.

NumberSeries

One-dimensional array for portex builtin number type.

StringSeries

One-dimensional array for portex builtin string type.

BinarySeries

One-dimensional array for portex builtin binary type.

ArraySeries

One-dimensional array for portex builtin type array.

FileSeries

One-dimensional array for file.

EnumSeries

One-dimensional array for portex builtin type enum.

TimeSeries

One-dimensional array for portex builtin temporal type.

Attributes#

pd

graviti.dataframe.column.series.pd[source]#
class graviti.dataframe.column.series.Series[source]#

Bases: graviti.dataframe.container.Container

One-dimensional array.

Parameters
  • data – The data that needs to be stored in Series. Could be ndarray or Iterable.

  • schema – Data type to force. If None, will be inferred from data.

Examples

Constructing Series from a list.

>>> d = [1,2,3,4]
>>> series = Series(data=d)
>>> series
0 1
1 2
2 3
3 4
classmethod from_pyarrow(cls, array)[source]#

Instantiate a Series backed by an pyarrow array.

Parameters

array (pyarrow.Array) – The input pyarrow array.

Raises

TypeError – When the input pyarrow type is not supported.

Returns

The loaded Series instance.

Return type

Series

classmethod from_pandas(cls, series)[source]#

Convert a pandas Series to a graviti Series.

Parameters

series (pandas.Series) – The input pandas Series.

Returns

The converted graviti Series.

Return type

Series

property iloc(self)[source]#

Purely integer-location based indexing for selection by position.

Allowed inputs are:

  • An integer, e.g. 5.

  • A list or array of integers, e.g. [4, 3, 0].

  • A slice object with ints, e.g. 1:7.

  • A boolean array of the same length as the axis being sliced.

Returns

The instance of the ILocIndexer.

Return type

graviti.dataframe.column.indexing.ColumnSeriesILocIndexer

Examples

>>> series = Series([1, 2, 3])
>>> series.loc[0]
1
>>> df.loc[[0]]
0    1
dtype: int64
property loc(self)[source]#

Access a group of rows and columns by indexes or a boolean array.

Allowed inputs are:

  • A single index, e.g. 5.

  • A list or array of indexes, e.g. [4, 3, 0].

  • A slice object with indexes, e.g. 1:7.

  • A boolean array of the same length as the axis being sliced.

Returns

The instance of the LocIndexer.

Return type

graviti.dataframe.column.indexing.ColumnSeriesLocIndexer

Examples

>>> series = Series([1, 2, 3])
>>> series.loc[0]
1
>>> df.loc[[0]]
0    1
dtype: int64
abstract to_pylist(self, *, _to_backend=False)[source]#

Convert the container to a python list.

Raises

NotImplementedError – The method of the base class should not be called.

Parameters

_to_backend (bool) –

Return type

List[Any]

abstract to_pandas(self)[source]#

Convert the graviti Container to a pandas Series or DataFrame.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

pandas.Series

class graviti.dataframe.column.series.PyarrowSeries[source]#

Bases: Series

Pyarrow based one-dimensional array.

to_pylist(self, *, _to_backend=False)[source]#

Convert the Series to a python list.

Returns

The python list representing the Series.

Parameters

_to_backend (bool) –

Return type

List[Any]

to_pandas(self)[source]#

Convert the graviti Series to a pandas Series.

Returns

The converted pandas Series.

Return type

pandas.Series

class graviti.dataframe.column.series.NumberSeries[source]#

Bases: PyarrowSeries

One-dimensional array for portex builtin number type.

class graviti.dataframe.column.series.StringSeries[source]#

Bases: PyarrowSeries

One-dimensional array for portex builtin string type.

class graviti.dataframe.column.series.BinarySeries[source]#

Bases: PyarrowSeries

One-dimensional array for portex builtin binary type.

class graviti.dataframe.column.series.ArraySeries[source]#

Bases: Series

One-dimensional array for portex builtin type array.

to_pylist(self, *, _to_backend=False)[source]#

Convert the Series to a python list.

Returns

The python list representing the Series.

Parameters

_to_backend (bool) –

Return type

List[Any]

to_pandas(self)[source]#

Convert the graviti Series to a pandas Series.

Returns

The converted pandas Series.

Return type

pandas.Series

class graviti.dataframe.column.series.FileSeries[source]#

Bases: Series

One-dimensional array for file.

to_pylist(self, *, _to_backend=False)[source]#

Convert the BinaryFileSeries to python list.

Returns

The python list.

Parameters

_to_backend (bool) –

Return type

List[Any]

to_pandas(self)[source]#

Convert the graviti Series to a pandas Series.

Returns

The converted pandas Series.

Return type

pandas.Series

class graviti.dataframe.column.series.EnumSeries[source]#

Bases: PyarrowSeries

One-dimensional array for portex builtin type enum.

to_pylist(self, *, _to_backend=False)[source]#

Convert the Series to a python list.

Returns

The python list representing the Series.

Parameters

_to_backend (bool) –

Return type

List[Any]

to_pandas(self)[source]#

Convert the graviti EnumSeries to a pandas Categorical Series.

Returns

The converted pandas Categorical Series.

Return type

pandas.Series

class graviti.dataframe.column.series.TimeSeries[source]#

Bases: PyarrowSeries

One-dimensional array for portex builtin temporal type.

to_pylist(self, *, _to_backend=False)[source]#

Convert the Series to a python list.

Returns

The python list representing the Series.

Parameters

_to_backend (bool) –

Return type

List[Any]