pyvisco.out¶
Collection of functions to write pandas dataframes to files or buffer.
Functions
|
Add second row units header to pandas dataframe containing. |
|
Write dataframe to csv file or returns bytes object with csv file content. |
- pyvisco.out.add_units(df, units, index_label=None)¶
Add second row units header to pandas dataframe containing.
A multiindex pandas dataframe is created. The first header row contains the physical quantities and the second row the corresponding physical units.
- Parameters:
df (pandas.DataFrame) – Units will be added to this dataframe.
units (dict of {str : str}) – Contains the names of the physical quantities as key and the corresponding names of the units as item.
index_label (str) – If index_label is specified, a name for the row index will be included in the multiindex column header.
- Returns:
df_out – Dataframe with a multiindex colum header containing the physical units.
- Return type:
pandas.DataFrame
See also
out.to_csvParent function of current function.
- pyvisco.out.to_csv(df, units, index_label=None, filepath=None)¶
Write dataframe to csv file or returns bytes object with csv file content.
This function adds units to the input dataframe and creates a csv file object. If filepath is specified the csv file is written to the specified location. If filepath is not specified a bytes object containing the csv file data is returned.
- Parameters:
df (pandas.DataFrame) – Dataframe to be written to csv file.
units (dict of {str : str}) – Contains the names of the physical quantities as key and the corresponding names of the units as item.
index_label (str) – If index_label is specified, a name for the row index will be included in the multiindex column header.
filepath (str, default = None) – Filepath to storage location of the new csv file.
- Returns:
If
filepathisNone, returns the CSV content as a string. Iffilepathis specified, the CSV is written to disk and the function returnsNone.- Return type:
str or None