Skip to content
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

Series.hist adds two bins when specifying bins #17280

Closed
2 tasks done
ggggggggg opened this issue Jun 28, 2024 · 2 comments
Closed
2 tasks done

Series.hist adds two bins when specifying bins #17280

ggggggggg opened this issue Jun 28, 2024 · 2 comments
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@ggggggggg
Copy link

ggggggggg commented Jun 28, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl
import numpy as np
series = pl.Series([1,2,3,4,4,5,6,3,2,1]).rename("a")
print(series.hist(np.arange(10)))

Log output

No response

Issue description

I didn't include inf or -inf in my bin edges, so I don't expect them in the output.

shape: (11, 3)
┌─────────────┬─────────────┬───────┐
│ break_point ┆ category    ┆ count │
│ ---         ┆ ---         ┆ ---   │
│ f64         ┆ cat         ┆ u32   │
╞═════════════╪═════════════╪═══════╡
│ 0.0         ┆ (-inf, 0.0] ┆ 0     │
│ 1.0         ┆ (0.0, 1.0]  ┆ 2     │
│ 2.0         ┆ (1.0, 2.0]  ┆ 2     │
│ 3.0         ┆ (2.0, 3.0]  ┆ 2     │
│ 4.0         ┆ (3.0, 4.0]  ┆ 2     │
│ …           ┆ …           ┆ …     │
│ 6.0         ┆ (5.0, 6.0]  ┆ 1     │
│ 7.0         ┆ (6.0, 7.0]  ┆ 0     │
│ 8.0         ┆ (7.0, 8.0]  ┆ 0     │
│ 9.0         ┆ (8.0, 9.0]  ┆ 0     │
│ inf         ┆ (9.0, inf]  ┆ 0     │
└─────────────┴─────────────┴───────┘

Expected behavior

Output I expect:

┌─────────────┬─────────────┬───────┐
│ break_point ┆ category    ┆ count │
│ ---         ┆ ---         ┆ ---   │
│ f64         ┆ cat         ┆ u32   │
╞═════════════╪═════════════╪═══════╡
│ 0.0         ┆ (0.0, 1.0]  ┆ 2     │
│ 1.0         ┆ (1.0, 2.0]  ┆ 2     │
│ 2.0         ┆ (2.0, 3.0]  ┆ 2     │
│ 3.0         ┆ (3.0, 4.0]  ┆ 2     │
│ …           ┆ …           ┆ …     │
│ 5.0         ┆ (5.0, 6.0]  ┆ 1     │
│ 6.0         ┆ (6.0, 7.0]  ┆ 0     │
│ 7.0         ┆ (7.0, 8.0]  ┆ 0     │
│ 8.0         ┆ (8.0, 9.0]  ┆ 0     │
└─────────────┴─────────────┴───────┘

Installed versions

--------Version info---------
Polars:               0.20.31
Index type:           UInt32
Platform:             Windows-10-10.0.19045-SP0
Python:               3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           3.7.2
nest_asyncio:         1.5.7
numpy:                1.24.4
openpyxl:             <not installed>
pandas:               2.1.0
pyarrow:              16.1.0
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           2.0.20
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@ggggggggg ggggggggg added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jun 28, 2024
@mcrumiller
Copy link
Contributor

Duplicate of #16912.

Open PR #16942 will fix.

@MarcoGorelli
Copy link
Collaborator

thanks @mcrumiller - closed by #16942? closing then but please let me know if I've misunderstood 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

3 participants