Numpy 2.0 shipped over the weekend. My dashboard automatically upgraded to 2.0 and, when using azure-kusto-data 4.4.1, I'm getting the following error from dataframe_from_result_table:
AttributeError: `np.NaN` was removed in the NumPy 2.0 release. Use `np.nan` instead.
np.nan is also available in earlier versions of numpy. Well, at least in the latest 1.x version (1.26.4). So I think it may be safe for you to just use np.nan instead of np.NaN regardless of the numpy version in use.
Some more context:
File ~/work/pyrx/pyrx/dashboard/chart_utils.py:21, in run_kql(client, query, database)
19 def run_kql(client: KustoClient, query: str, database: str = "VSCodeExt") -> pd.DataFrame:
20 response = client.execute(database, query)
---> 21 return dataframe_from_result_table(response.primary_results[0])
File /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/azure/kusto/data/helpers.py:63, in dataframe_from_result_table(table, nullable_bools)
61 frame[col.column_name] = frame[col.column_name].astype(pd.Int64Dtype())
62 elif col.column_type == "real" or col.column_type == "decimal":
---> 63 frame[col.column_name] = frame[col.column_name].replace("NaN", np.NaN).replace("Infinity", np.PINF).replace("-Infinity", np.NINF)
64 frame[col.column_name] = pd.to_numeric(frame[col.column_name], errors="coerce").astype(pd.Float64Dtype())
65 elif col.column_type == "datetime":
66 # Pandas before version 2 doesn't support the "format" arg
File /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/numpy/__init__.py:397, in __getattr__(attr)
394 raise AttributeError(__former_attrs__[attr])
396 if attr in __expired_attributes__:
--> 397 raise AttributeError(
398 f"`np.{attr}` was removed in the NumPy 2.0 release. "
399 f"{__expired_attributes__[attr]}"
400 )
402 if attr == "chararray":
403 warnings.warn(
404 "`np.chararray` is deprecated and will be removed from "
405 "the main namespace in the future. Use an array with a string "
406 "or bytes dtype instead.", DeprecationWarning, stacklevel=2)
Code Sample, a copy-pastable example if possible
Problem description
Numpy 2.0 shipped over the weekend. My dashboard automatically upgraded to 2.0 and, when using azure-kusto-data 4.4.1, I'm getting the following error from
dataframe_from_result_table
:np.nan
is also available in earlier versions of numpy. Well, at least in the latest 1.x version (1.26.4). So I think it may be safe for you to just usenp.nan
instead ofnp.NaN
regardless of the numpy version in use.Some more context:
Output of
pip freeze