Skip to content

Commit

Permalink
restore arch dataframe (#4663)
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Wu <yolandawu131@gmail.com>
  • Loading branch information
nemirorox committed Jun 13, 2023
1 parent 46f9b14 commit 48dbaf2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions python/fate/arch/dataframe/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ def sigmoid(self) -> "DataFrame":
def count(self) -> "int":
return self.shape[0]

def describe(self, ddof=1, unbiased=False):
def describe(self, metric_kwargs=None):
from .ops._stat import describe
return describe(self, ddof=ddof, unbiased=unbiased)
if metric_kwargs is None:
metric_kwargs = dict()
return describe(self, metric_kwargs)

def quantile(self, q, axis=0, method="quantile", ):
...
Expand Down
13 changes: 7 additions & 6 deletions python/fate/arch/dataframe/ops/_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,18 @@ def variation(df: "DataFrame", ddof=1):
return std(df, ddof==ddof) / mean(df)


def describe(df: "DataFrame", ddof=1, unbiased=False):
def describe(df: "DataFrame", metric_kwargs):
stat_metrics = dict()
stat_metrics["sum"] = sum(df)
stat_metrics["min"] = min(df)
stat_metrics["max"] = max(df)
stat_metrics["mean"] = mean(df)
stat_metrics["std"] = std(df, ddof=ddof)
stat_metrics["var"] = var(df, ddof=ddof)
stat_metrics["variation"] = variation(df, ddof=ddof)
stat_metrics["skew"] = skew(df, unbiased=unbiased)
stat_metrics["kurt"] = kurt(df, unbiased=unbiased)
stat_metrics["std"] = std(df) if "std" not in metric_kwargs else std(df, ddof=metric_kwargs["std"])
stat_metrics["var"] = var(df) if "var" not in metric_kwargs else var(df, ddof=metric_kwargs["var"])
stat_metrics["variation"] = variation(df) if "variation" not in metric_kwargs else variation(df, ddof=metric_kwargs[
"variation"])
stat_metrics["skew"] = skew(df) if "skew" not in metric_kwargs else skew(df, unbiased=metric_kwargs["unbiased"])
stat_metrics["kurt"] = kurt(df) if "kurt" not in metric_kwargs else kurt(df, unbiased=metric_kwargs["unbiased"])
stat_metrics["na_count"] = df.isna().sum()

return pd.DataFrame(stat_metrics)
Expand Down

0 comments on commit 48dbaf2

Please sign in to comment.