Dios Methods and Properies ======================== Methods -------- Brief - `copy(deep=True)` : Return a copy. See also [pandas.DataFrame.copy]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.copy.html) - `copy_empty()` : Return a new DictOfSeries object, with same properties than the original. - `all(axis=0)` : Return whether all elements are True, potentially over an axis. See also [pandas.DataFrame.all]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.all.html) - `any(axis=0)` : Return whether any element is True, potentially over an axis. See also [pandas.DataFrame.any]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.any.html) - `squeeze(axis=None)` : Squeeze a 1-dimensional axis objects into scalars. Eg. a 1-column Dios is squeezes to the underling Series. If `axis=None` it is also tried, to squeeze the possibly returned Series, from the (outer) Dios-squeeze. See also [pandas.DataFrame.squeeze](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.squeeze.html) - `to_df()` : Transform the Dios to a pandas.DataFrame - `to_string(kwargs)` : Return a string representation of the Dios. - `apply(func, args=(), **kwds)` : apply the given function to every column in the dios eg. - `astype()` : Cast the data to the given data type. - `isin()` : return a boolean dios, that indicates if the corresponding value is in the given array-like - `isna()` : Return a bolean array that is `True` if the value is a Nan-value - `notna()` : inverse of `isnan()` - `dropna()` : drop all Nan-values - `index_of(method='union)`: Return a single(!) Index that is constructed from all the indexes of the columns. - `in` - `is` - `len(Dios)` : return the number of columns the dios has. `copy_empty(columns=True)` -------------------------- Return a new DictOfSeries object, with same properties than the original. If `columns=True`, the copy will have the same, but empty columns like the original. **Parameter**: - **columns : bool, default True** Function to apply to each column or row. **Examples** ``` >>> d a | b | c | d | ===== | ==== | ===== | ===== | 0 0 | 2 5 | 4 7 | 6 0 | 1 7 | 3 6 | 5 17 | 7 1 | 2 14 | 4 7 | 6 27 | 8 2 | 3 21 | 5 8 | 7 37 | 9 3 | 4 28 | 6 9 | 8 47 | 10 4 | >>> d.copy_empty() Empty DictOfSeries Columns: ['a', 'b', 'c', 'd'] >>> d.copy_empty(columns=False) Empty DictOfSeries Columns: [] ``` `to_df()` --------- Transform the Dios to a pandas.DataFrame. Missing common indices are filled with NaN's. **Examples** ``` >>> d a | b | c | d | ===== | ==== | ===== | ===== | 0 0 | 2 5 | 4 7 | 6 0 | 1 7 | 3 6 | 5 17 | 7 1 | 2 14 | 4 7 | 6 27 | 8 2 | 3 21 | 5 8 | 7 37 | 9 3 | 4 28 | 6 9 | 8 47 | 10 4 | >>> d.to_df() columns a b c d 0 0.0 NaN NaN NaN 1 7.0 NaN NaN NaN 2 14.0 5.0 NaN NaN 3 21.0 6.0 NaN NaN 4 28.0 7.0 7.0 NaN 5 NaN 8.0 17.0 NaN 6 NaN 9.0 27.0 0.0 7 NaN NaN 37.0 1.0 8 NaN NaN 47.0 2.0 9 NaN NaN NaN 3.0 10 NaN NaN NaN 4.0 ``` dios.DictOfSeries.apply ------------------------------------------------- `apply(func, axis=0, raw=False, args=(), **kwds)` Apply the given function to every column in the dios. This is a very mighty tool to apply functions that are defined on pandas.Series to multiple columns. **Parameters:** - **func : function** Function to apply to each column or row. - **axis : {0 or ‘index’, 1 or ‘columns’}, default 0** Axis along which the function is applied: - 0 or ‘index’: apply function to each column. - ~~1 or ‘columns’: apply function to each row~~. **not implemented** - **raw : bool, default False** Determines if row or column is passed as a Series or ndarray object: - `False` : passes each row or column as a Series to the function. - `True` : the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance. - **args : tuple** Positional arguments to pass to func in addition to the array/series. - ****kwds** Additional keyword arguments to pass as keywords arguments to func. **Returns: Series or DataFrame** - Result of applying func along the given axis of the DataFrame. **See also** [pandas.DataFrame.apply](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.apply.html) **Examples** ``` >>> d a | b | c | d | ===== | ==== | ===== | ===== | 0 0 | 2 5 | 4 7 | 6 0 | 1 7 | 3 6 | 5 17 | 7 1 | 2 14 | 4 7 | 6 27 | 8 2 | 3 21 | 5 8 | 7 37 | 9 3 | 4 28 | 6 9 | 8 47 | 10 4 | >>> d.apply(max) columns a 28 b 9 c 47 d 4 dtype: int64 >>> d.apply(pd.Series.count) columns a 5 b 5 c 5 d 5 dtype: int64 >>> d.apply(pd.Series.value_counts, normalize=True) a | b | c | d | ======= | ====== | ======= | ====== | 7 0.2 | 7 0.2 | 7 0.2 | 4 0.2 | 14 0.2 | 6 0.2 | 37 0.2 | 3 0.2 | 21 0.2 | 5 0.2 | 47 0.2 | 2 0.2 | 28 0.2 | 9 0.2 | 27 0.2 | 1 0.2 | 0 0.2 | 8 0.2 | 17 0.2 | 0 0.2 | >>> d.apply(lambda s : 'high' if max(s) > 10 else 'low') columns a high b low c high d low dtype: object >>> d.apply(lambda s : ('high', max(s)) if min(s) > (max(s)//2) else ('low',max(s))) a | b | c | d | ====== | ======= | ====== | ====== | 0 low | 0 high | 0 low | 0 low | 1 28 | 1 9 | 1 47 | 1 4 | ``` dios.DictOfSeries.index_of --------------------------- `index_of(method='union)` : return a single(!) Index that is constructed from all the indexes of the columns. Properties ---------- - `columns` : Column index - `indexes` : Series of indexes of columns - `lengths` : Series of lengths of columns - `values` : A array of length of the columns, with arrays of values, as sub-arrays - `dtypes` : Series of dtypes of columns - `itype` : The index type the Dios accept - `empty` : True if the dios holds no data. Nevertheless the dios can have empty columns.