Skip to content

Commit

Permalink
return nan for float (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHYang authored Apr 4, 2023
1 parent 756108e commit 8183737
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/phoenix/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ def calc(self, dataframe: pd.DataFrame) -> float:

@dataclass
class Cardinality(UnaryOperator, BaseMetric):
def calc(self, dataframe: pd.DataFrame) -> int:
def calc(self, dataframe: pd.DataFrame) -> float:
data = self.get_operand_column(dataframe)
return data.nunique()
if data.dtype.kind == "f":
return float("nan")
return cast(float, data.nunique())


@dataclass
Expand Down

0 comments on commit 8183737

Please sign in to comment.