Detail: Series: Constructor
- Series.__init__(values, *, index=None, name=<object object>, dtype=None, index_constructor=None, own_index=False)[source]
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.Series((10, 2, 8), index=('a', 'b', 'c')) <Series> <Index> a 10 b 2 c 8 <<U1> <int64>
- classmethod Series.from_concat(containers, *, index=None, index_constructor=None, name=<object object>)[source]
Concatenate multiple
Series
into a newSeries
.- Parameters:
containers – Iterable of
Series
from which values in the newSeries
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:
>>> s1 = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s1 <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s2 = sf.Series((4, 3, 12), index=('d', 'e', 'f')) >>> s2 <Series> <Index> d 4 e 3 f 12 <<U1> <int64> >>> sf.Series.from_concat((s1, s2)) <Series> <Index> a 10 b 2 c 8 d 4 e 3 f 12 <<U1> <int64>
- classmethod Series.from_concat_items(items, *, name=None, index_constructor=None)[source]
Produce a
Series
with a hierarchical index from an iterable of pairs of labels,Series
. TheIndexHierarchy
is formed from the provided labels and theIndex
if eachSeries
.- Parameters:
items – Iterable of pairs of label,
Series
- Returns:
>>> s1 = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s1 <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s2 = sf.Series((4, 3, 12), index=('d', 'e', 'f')) >>> s2 <Series> <Index> d 4 e 3 f 12 <<U1> <int64> >>> sf.Series.from_concat_items((('x', s1), ('y', s2))) <Series> <IndexHierarchy> x a 10 x b 2 x c 8 y d 4 y e 3 y f 12 <<U1> <<U1> <int64>
- classmethod Series.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)[source]
Series construction from a delimited string.
- Parameters:
dtype – if None, dtype will be inferred.
>>> sf.Series.from_delimited('1.2|5.5|8.2|-3.0', delimiter='|') <Series> <Index> 0 1.2 1 5.5 2 8.2 3 -3.0 <int64> <float64> >>> sf.Series.from_delimited('2021-01:1517-04:1620-12', delimiter=':', dtype=np.datetime64) <Series> <Index> 0 2021-01 1 1517-04 2 1620-12 <int64> <datetime64[M]>
- classmethod Series.from_dict(mapping, *, dtype=None, name=None, index_constructor=None)[source]
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:
>>> sf.Series.from_dict(dict(a=10, b=2, c=8)) <Series> <Index> a 10 b 2 c 8 <<U1> <int64>
- classmethod Series.from_element(element, *, index, dtype=None, name=None, index_constructor=None, own_index=False)[source]
Create a
static_frame.Series
from a single element. The size of the resultant container will be determined by theindex
argument.- Returns:
>>> sf.Series.from_element(-1, index=('a', 'b', 'c'), name='x') <Series: x> <Index> a -1 b -1 c -1 <<U1> <int64>
- classmethod Series.from_items(pairs, *, dtype=None, name=None, index_constructor=None)[source]
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:
>>> sf.Series.from_items((('a', 10), ('b', 2), ('c', 8)), name='x') <Series: x> <Index> a 10 b 2 c 8 <<U1> <int64>
- classmethod Series.from_overlay(containers, *, index=None, union=True, name=None, func=<function isna_array>, fill_value=<object object>)[source]
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
orIndexHierarchy
, 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 fromcontainers
will be used; if False, the intersection index will be used.name –
func –
fill_value –
>>> s1 = sf.Series((11, 1, None), index=('a', 'b', 'c')) >>> s1 <Series> <Index> a 11 b 1 c None <<U1> <object> >>> s2 = sf.Series((2, 8, 19), index=('b', 'c', 'd')) >>> s2 <Series> <Index> b 2 c 8 d 19 <<U1> <int64> >>> sf.Series.from_overlay((s1, s2)) <Series> <Index> a 11 b 1 c 8 d 19 <<U1> <object>
- classmethod Series.from_pandas(value, *, index=None, index_constructor=None, name=<object object>, own_data=False)[source]
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:
>>> df = pd.Series((10, 2, 8), index=('a', 'b', 'c')) >>> sf.Series.from_pandas(df) <Series> <Index> a 10 b 2 c 8 <object> <int64>
Series: 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 | Accessor Type Clinic