Pandas DataFrame Manipulation¶
- pydiana.tools.dataframe_manip.dataframe_insert(df1, df2, row=0)[source]¶
Function for inserting a pandas dataframe in another dataframe at a certain row
- Parameters:
df1 (dataframe to be inserted) --
df2 (dataframe that hosts the insertions) --
row (index of the row of insertion) --
- Returns:
Modified dataframe or None if failed
- pydiana.tools.dataframe_manip.extract_fit_dataframe_columns(fit_res, *labels2extract, points2skip=None, getError=True, output_col_names=None, compress=False)[source]¶
Extract gaussians fit results into a Pandas dataframe (both values and errors by default); first label2extract determines the order of points2skip (for example put "Mean" first if you want to use it as reference)
- Parameters:
(dict) (points2skip) --
labels2extract (str or list of str (for example "Mean" and/or "StdDev")) --
(dict) --
(bool) (getError) --
output_col_names (new names to be given to output dataframe. If None the default names are given, if list the names are substituted in order as present in the dataframe. If dict then it is a 1 to 1 mapping of the column names. If less names are provided then only the specified columns will be overwritten.) --
- Returns:
result
- Return type:
Pandas dataframe with labels2extract as columns (with errors or not)
- pydiana.tools.dataframe_manip.find_row(df, index)[source]¶
Function for finding the row that has the content of 'index' as index (used mainly for non-numerical indexes :type df: :param df: :type df: pandas dataframe :type index: :param index: :type index: index content to be found
- Returns:
Row number or None if failed
- pydiana.tools.dataframe_manip.multi_display(df, *args, **kwargs)[source]¶
Display one or more pandas data frames (usefull because display(list) is not implemented
- Parameters:
df (single/list/dict of Pandas data frame to be printed) --
*args (additional parameters for display function) --
**kwargs (additional parameters for display function) --
- Return type:
None
- pydiana.tools.dataframe_manip.pandas_row_swap(df, i, j)[source]¶
Function for easy pandas dataframe row swapping
- Parameters:
df (pandas dataframe) --
i (first index to swap (either int to indicate row or elemend of the index column)) --
j (second index to swap (either int to indicate row or elemend of the index column)) --
- Returns:
Modified Dataframe or None if failed