Skip to content

Commit 65cb7c4

Browse files
authored
BUG: info raising when use_numba is set (#52077)
1 parent 72f06ef commit 65cb7c4

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

doc/source/whatsnew/v2.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Numeric
162162
Conversion
163163
^^^^^^^^^^
164164
- Bug in :meth:`ArrowDtype.numpy_dtype` returning nanosecond units for non-nanosecond ``pyarrow.timestamp`` and ``pyarrow.duration`` types (:issue:`51800`)
165+
- Bug in :meth:`DataFrame.info` raising ``ValueError`` when ``use_numba`` is set (:issue:`51922`)
165166
-
166167

167168
Strings

pandas/io/formats/info.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
Sequence,
1515
)
1616

17+
import numpy as np
18+
1719
from pandas._config import get_option
1820

1921
from pandas.io.formats import format as fmt
@@ -1097,4 +1099,4 @@ def _get_dataframe_dtype_counts(df: DataFrame) -> Mapping[str, int]:
10971099
Create mapping between datatypes and their number of occurrences.
10981100
"""
10991101
# groupby dtype.name to collect e.g. Categorical columns
1100-
return df.dtypes.value_counts().groupby(lambda x: x.name).sum()
1102+
return df.dtypes.value_counts().groupby(lambda x: x.name).sum().astype(np.intp)

pandas/tests/io/formats/test_info.py

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
IS64,
1212
PYPY,
1313
)
14+
import pandas.util._test_decorators as td
1415

1516
from pandas import (
1617
CategoricalIndex,
@@ -501,3 +502,19 @@ def test_memory_usage_empty_no_warning():
501502
result = df.memory_usage()
502503
expected = Series(16 if IS64 else 8, index=["Index"])
503504
tm.assert_series_equal(result, expected)
505+
506+
507+
@td.skip_if_no("numba")
508+
def test_info_compute_numba():
509+
# GH#51922
510+
df = DataFrame([[1, 2], [3, 4]])
511+
512+
with option_context("compute.use_numba", True):
513+
buf = StringIO()
514+
df.info()
515+
result = buf.getvalue()
516+
517+
buf = StringIO()
518+
df.info()
519+
expected = buf.getvalue()
520+
assert result == expected

0 commit comments

Comments
 (0)