Skip to content

BUG: info raising when use_numba is set #52077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Numeric
Conversion
^^^^^^^^^^
- Bug in :meth:`ArrowDtype.numpy_dtype` returning nanosecond units for non-nanosecond ``pyarrow.timestamp`` and ``pyarrow.duration`` types (:issue:`51800`)
- Bug in :meth:`DataFrame.info` raising ``ValueError`` when ``use_numba`` is set (:issue:`51922`)
-

Strings
Expand Down
4 changes: 3 additions & 1 deletion pandas/io/formats/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
Sequence,
)

import numpy as np

from pandas._config import get_option

from pandas.io.formats import format as fmt
Expand Down Expand Up @@ -1097,4 +1099,4 @@ def _get_dataframe_dtype_counts(df: DataFrame) -> Mapping[str, int]:
Create mapping between datatypes and their number of occurrences.
"""
# groupby dtype.name to collect e.g. Categorical columns
return df.dtypes.value_counts().groupby(lambda x: x.name).sum()
return df.dtypes.value_counts().groupby(lambda x: x.name).sum().astype(np.intp)
17 changes: 17 additions & 0 deletions pandas/tests/io/formats/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
IS64,
PYPY,
)
import pandas.util._test_decorators as td

from pandas import (
CategoricalIndex,
Expand Down Expand Up @@ -501,3 +502,19 @@ def test_memory_usage_empty_no_warning():
result = df.memory_usage()
expected = Series(16 if IS64 else 8, index=["Index"])
tm.assert_series_equal(result, expected)


@td.skip_if_no("numba")
def test_info_compute_numba():
# GH#51922
df = DataFrame([[1, 2], [3, 4]])

with option_context("compute.use_numba", True):
buf = StringIO()
df.info()
result = buf.getvalue()

buf = StringIO()
df.info()
expected = buf.getvalue()
assert result == expected