Detail: SeriesHE: Constructor

Overview: SeriesHE: Constructor

SeriesHE.__init__(values, *, index=None, name=<object object>, dtype=None, index_constructor=None, own_index=False)

Initializer.

Parameters
  • values – An iterable of values to be aligned with the supplied (or automatically generated) index.

  • index – Optional index initializer. If provided in addition to data values, lengths must be compatible.

  • name

  • dtype

  • index_constructor

  • own_index – Flag the passed index as ownable by this static_frame.Series. Primarily used by internal clients.

>>> sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
<SeriesHE>
<Index>
a          10
b          2
c          8
<<U1>      <int64>
classmethod SeriesHE.from_concat(containers, *, index=None, index_constructor=None, name=<object object>)

Concatenate multiple Series into a new Series.

Parameters
  • containers – Iterable of Series from which values in the new Series are drawn.

  • index – If None, the resultant index will be the concatenation of all indices (assuming they are unique in combination). If IndexAutoFactory, the resultant index is a auto-incremented integer index. Otherwise, the value is used as a index initializer.

  • index_constructor

  • name

Returns

static_frame.Series

>>> s1 = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s2 = sf.SeriesHE((4, 3, 12), index=('d', 'e', 'f'))
>>> sf.SeriesHE.from_concat((s1, s2))
<SeriesHE>
<Index>
a          10
b          2
c          8
d          4
e          3
f          12
<<U1>      <int64>
classmethod SeriesHE.from_concat_items(items, *, name=None, index_constructor=None)

Produce a Series with a hierarchical index from an iterable of pairs of labels, Series. The IndexHierarchy is formed from the provided labels and the Index if each Series.

Parameters

items – Iterable of pairs of label, Series

Returns

static_frame.Series

>>> s1 = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s2 = sf.SeriesHE((4, 3, 12), index=('d', 'e', 'f'))
>>> sf.SeriesHE.from_concat_items((('x', s1), ('y', s2)))
<SeriesHE>
<IndexHierarchy>
x                a     10
x                b     2
x                c     8
y                d     4
y                e     3
y                f     12
<<U1>            <<U1> <int64>
classmethod SeriesHE.from_delimited(delimited, *, delimiter, index=None, dtype=None, name=None, index_constructor=None, skip_initial_space=False, quoting=0, quote_char='"', quote_double=True, escape_char=None, thousands_char='', decimal_char='.', own_index=False)

Series construction from a delimited string.

Parameters

dtype – if None, dtype will be inferred.

>>> sf.SeriesHE.from_delimited('1.2|5.5|8.2|-3.0', delimiter='|')
<SeriesHE>
<Index>
0          1.2
1          5.5
2          8.2
3          -3.0
<int64>    <float64>
>>> sf.SeriesHE.from_delimited('2021-01:1517-04:1620-12', delimiter=':', dtype=np.datetime64)
<SeriesHE>
<Index>
0          2021-01
1          1517-04
2          1620-12
<int64>    <datetime64[M]>
classmethod SeriesHE.from_dict(mapping, *, dtype=None, name=None, index_constructor=None)

Series construction from a dictionary, where the first pair value is the index and the second is the value.

Parameters
  • mapping – a dictionary or similar mapping interface.

  • dtype – dtype or valid dtype specifier.

Returns

Series

>>> sf.SeriesHE.from_dict(dict(a=10, b=2, c=8))
<SeriesHE>
<Index>
a          10
b          2
c          8
<<U1>      <int64>
classmethod SeriesHE.from_element(element, *, index, dtype=None, name=None, index_constructor=None, own_index=False)

Create a static_frame.Series from a single element. The size of the resultant container will be determined by the index argument.

Returns

static_frame.Series

>>> sf.SeriesHE.from_element(-1, index=('a', 'b', 'c'), name='x')
<SeriesHE: x>
<Index>
a             -1
b             -1
c             -1
<<U1>         <int64>
classmethod SeriesHE.from_items(pairs, *, dtype=None, name=None, index_constructor=None)

Series construction from an iterator or generator of pairs, where the first pair value is the index and the second is the value.

Parameters
  • pairs – Iterable of pairs of index, value.

  • dtype – dtype or valid dtype specifier.

  • name

  • index_constructor

Returns

static_frame.Series

>>> sf.SeriesHE.from_items((('a', 10), ('b', 2), ('c', 8)), name='x')
<SeriesHE: x>
<Index>
a             10
b             2
c             8
<<U1>         <int64>
classmethod SeriesHE.from_overlay(containers, *, index=None, union=True, name=None, func=<function isna_array>, fill_value=<object object>)

Return a new Series made by overlaying containers, aligned values are filled with values from subsequent containers with left-to-right precedence. Values are filled based on a passed function that must return a Boolean array. By default, that function is isna_array, returning True for missing values (NaN and None).

Parameters
  • containers – Iterable of Series.

  • *,

  • index – An Index or IndexHierarchy, or index initializer, to be used as the index upon which all containers are aligned. IndexAutoFactory is not supported.

  • union – If True, and no index argument is supplied, a union index from containers will be used; if False, the intersection index will be used.

  • name

  • func

  • fill_value

>>> s1 = sf.SeriesHE((11, 1, None), index=('a', 'b', 'c'))
>>> s1
<SeriesHE>
<Index>
a          11
b          1
c          None
<<U1>      <object>
>>> s2 = sf.SeriesHE((2, 8, 19), index=('b', 'c', 'd'))
>>> sf.SeriesHE.from_overlay((s1, s2))
<SeriesHE>
<Index>
a          11
b          1
c          8
d          19
<<U1>      <object>
classmethod SeriesHE.from_pandas(value, *, index=None, index_constructor=None, name=<object object>, own_data=False)

Given a Pandas Series, return a Series.

Parameters
  • value – Pandas Series.

  • *

  • index_constructor

  • name

  • own_data – If True, the underlying NumPy data array will be made immutable and used without a copy.

Returns

static_frame.Series

>>> df = pd.Series((10, 2, 8), index=('a', 'b', 'c'))
>>> sf.SeriesHE.from_pandas(df)
<SeriesHE>
<Index>
a          10
b          2
c          8
<object>   <int64>

SeriesHE: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Assignment | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib