larray.Array.to_series

Array.to_series(name=None, dropna=False) Series[source]

Convert an Array into a Pandas Series.

Parameters
namestr, optional

Name of the series. Defaults to None.

dropnabool, optional.

False by default.

Returns
Pandas Series

Notes

Since pandas does not provide a way to handle metadata (yet), all metadata associated with the array will be lost.

Examples

>>> arr = ndtest((2, 3), dtype=float)
>>> arr
a\b   b0   b1   b2
 a0  0.0  1.0  2.0
 a1  3.0  4.0  5.0
>>> arr.to_series() 
a   b
a0  b0    0.0
    b1    1.0
    b2    2.0
a1  b0    3.0
    b1    4.0
    b2    5.0
dtype: float64

Set a name

>>> arr.to_series('my_name') 
        a   b
a0  b0    0.0
    b1    1.0
    b2    2.0
a1  b0    3.0
    b1    4.0
    b2    5.0
Name: my_name, dtype: float64

Drop NaN values

>>> arr['b1'] = nan
>>> arr
a\b   b0   b1   b2
 a0  0.0  nan  2.0
 a1  3.0  nan  5.0
>>> arr.to_series(dropna=True) 
a   b
a0  b0    0.0
    b2    2.0
a1  b0    3.0
    b2    5.0
dtype: float64