From 07bc2cf4c2ccfc39fd0d8a6e0d4112f9d4ef25a1 Mon Sep 17 00:00:00 2001 From: Victor Ramirez Date: Thu, 19 Sep 2024 14:38:40 +0000 Subject: [PATCH] PLAT-1037 Fix type casting for coin_metrics_id This MR fixes the occasional bug where coin_metrics_id is a string --- coinmetrics/_data_collection.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coinmetrics/_data_collection.py b/coinmetrics/_data_collection.py index 54f811d..bca17d2 100644 --- a/coinmetrics/_data_collection.py +++ b/coinmetrics/_data_collection.py @@ -30,6 +30,7 @@ from coinmetrics._exceptions import CoinMetricsClientNotFoundError if TYPE_CHECKING: from coinmetrics.api_client import CoinMetricsClient +import numpy as np orjson_found = True try: @@ -285,6 +286,8 @@ def to_dataframe( ) if dtype_mapper is None: df = df.convert_dtypes() + if df.dtypes.get("coin_metrics_id") == np.dtype("object"): + df["coin_metrics_id"] = df["coin_metrics_id"].astype(np.float128) if header is not None: assert len(df.columns) == len( header