Skip to content

BUG: AttributeError: 'BooleanArray' object has no attribute 'sum' while infer types #44079 #44442

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 22 commits into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
522ffa8
BUG GH44079 fix
zhangxiaoxing Nov 13, 2021
eb8d28b
BUG GH44079 pre-commit checked
zhangxiaoxing Nov 13, 2021
908389a
BUG GH44079 added test
zhangxiaoxing Nov 14, 2021
fa43054
BUG GH44079 typofix
zhangxiaoxing Nov 14, 2021
3762579
Merge pull request #1 from pandas-dev/master
zhangxiaoxing Nov 14, 2021
a486c1f
Merge branch 'master' into BUG_GH44079
zhangxiaoxing Nov 14, 2021
4e55c97
BUG GH44079
zhangxiaoxing Nov 14, 2021
6c59cdd
Merge branch 'pandas-dev:master' into master
zhangxiaoxing Nov 15, 2021
a406865
BUG GH44079 refined dtype conversion
zhangxiaoxing Nov 15, 2021
02ac563
BUG GH44079 added whatsnew note
zhangxiaoxing Nov 15, 2021
8afe3cc
Merge branch 'pandas-dev:master' into master
zhangxiaoxing Nov 17, 2021
0ff84fc
BUG GH44079 Added more specific comment.
zhangxiaoxing Nov 17, 2021
067b259
Merge branch 'pandas-dev:master' into BUG_GH44079
zhangxiaoxing Nov 17, 2021
292db96
Merge branch 'pandas-dev:master' into BUG_GH44079
zhangxiaoxing Nov 17, 2021
a6f232d
Merge branch 'pandas-dev:master' into master
zhangxiaoxing Nov 18, 2021
eadc6aa
Merge branch 'master' into BUG_GH44079
zhangxiaoxing Nov 18, 2021
dabc157
Merge branch 'BUG_GH44079' of https://github.com/zhangxiaoxing/pandas…
zhangxiaoxing Nov 18, 2021
1650955
Merge branch 'pandas-dev:master' into BUG_GH44079
zhangxiaoxing Nov 18, 2021
925ce8a
Merge branch 'pandas-dev:master' into BUG_GH44079
zhangxiaoxing Nov 19, 2021
6d5fa07
Merge branch 'pandas-dev:master' into BUG_GH44079
zhangxiaoxing Nov 19, 2021
706ea4a
Merge branch 'pandas-dev:master' into BUG_GH44079
zhangxiaoxing Nov 19, 2021
c90bb30
Merge branch 'pandas-dev:master' into BUG_GH44079
zhangxiaoxing Nov 20, 2021
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
2 changes: 1 addition & 1 deletion doc/source/user_guide/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ The ``period`` dtype can be used in ``.astype(...)``. It allows one to change th
pi.astype("period[D]")

# convert to DatetimeIndex
pi.astype("datetime64[ns]")
pi.to_timestamp()

# convert to PeriodIndex
dti = pd.date_range("2011-01-01", freq="M", periods=3)
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def _infer_types(self, values, na_values, try_num_bool=True):
# error: Argument 2 to "isin" has incompatible type "List[Any]"; expected
# "Union[Union[ExtensionArray, ndarray], Index, Series]"
mask = algorithms.isin(values, list(na_values)) # type: ignore[arg-type]
na_count = mask.sum()
na_count = mask.astype("uint8").sum()
if na_count > 0:
if is_integer_dtype(values):
values = values.astype(np.float64)
Expand Down
21 changes: 21 additions & 0 deletions pandas/tests/io/parser/test_index_col.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,24 @@ def test_multiindex_columns_index_col_with_data(all_parsers):
index=Index(["data"]),
)
tm.assert_frame_equal(result, expected)


@skip_pyarrow
def test_infer_types_boolean_sum(all_parsers):
# GH#44079
parser = all_parsers
result = parser.read_csv(
StringIO("0,1"),
names=["a", "b"],
index_col=["a"],
dtype={"a": "UInt8"},
)
expected = DataFrame(
data={
"a": [
0,
],
"b": [1],
}
).set_index("a")
tm.assert_frame_equal(result, expected, check_index_type=False)