psweep.psweep.df_print#
- psweep.psweep.df_print(df, index=False, special_cols=None, prefix_cols=False, cols=[], skip_cols=[])[source]#
Print DataFrame, by default without the index and prefix columns such as _pset_id.
Similar logic as in bin/psweep-db2table, w/o tabulate support but more features (skip_cols for instance).
Column names are always sorted, so the order of names in e.g. cols doesn’t matter.
- Parameters:
df (
DataFrame
)index (
bool
) – include DataFrame indexprefix_cols (
bool
) – include all prefix columns (_pset_id etc.), we don’t support skipping user-added postfix columns (e.g. result_)cols (
Sequence
[str
]) – explicit sequence of columns, overrides prefix_cols when prefix columns are specifiedskip_cols (
Sequence
[str
]) – skip those columns instead of selecting them (like cols would), use either this or cols; overrides prefix_cols when prefix columns are specified
Examples
>>> import pandas as pd >>> df=pd.DataFrame(dict(a=rand(3), b=rand(3), _c=rand(3)))
>>> df a b _c 0 0.373534 0.304302 0.161799 1 0.698738 0.589642 0.557172 2 0.343316 0.186595 0.822023
>>> ps.df_print(df) a b 0.373534 0.304302 0.698738 0.589642 0.343316 0.186595
>>> ps.df_print(df, prefix_cols=True) a b _c 0.373534 0.304302 0.161799 0.698738 0.589642 0.557172 0.343316 0.186595 0.822023
>>> ps.df_print(df, index=True) a b 0 0.373534 0.304302 1 0.698738 0.589642 2 0.343316 0.186595
>>> ps.df_print(df, cols=["a"]) a 0.373534 0.698738 0.343316
>>> ps.df_print(df, cols=["a"], prefix_cols=True) a _c 0.373534 0.161799 0.698738 0.557172 0.343316 0.822023
>>> ps.df_print(df, cols=["a", "_c"]) a _c 0.373534 0.161799 0.698738 0.557172 0.343316 0.822023
>>> ps.df_print(df, skip_cols=["a"]) b 0.304302 0.589642 0.186595