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

Constructing Series with dtype pl.List(pl.Float32) rounds inputs to integers #9500

Closed
2 tasks done
SujeetO opened this issue Jun 22, 2023 · 9 comments
Closed
2 tasks done
Labels
bug Something isn't working python Related to Python Polars

Comments

@SujeetO
Copy link

SujeetO commented Jun 22, 2023

Research

  • I have searched the above polars tags on Stack Overflow for similar questions.

  • I have asked my usage related question on Stack Overflow.

Link to question on Stack Overflow

No response

Question about Polars

I am using '0.18.3' version of polars and seeing below problem:


x = pl.Series([[1,2],[2.6,3],[3,4,4.4]] )
print(x)

shape: (3,)
Series: '' [list[i64]]
[
[1, 2]
[2, 3]
[3, 4, 4]
]

it has converted the float number to int without any warning or error. it this expected?

@SujeetO
Copy link
Author

SujeetO commented Jun 22, 2023

If yes, how can I avoid that?

@ion-elgreco
Copy link
Contributor

You can specify the dtype while creating it:

x = pl.Series([[1,2],[2.6,3],[3,4,4.4]], dtype=pl.List(pl.Float32)) 

@MarcoGorelli
Copy link
Collaborator

would your expected outcome be that dtype=pl.List(pl.Int64) raise an error, instead of rounding the 4.4 to 4? If so, then this sounds related to #9119 (it's different though, not a duplicate, just bringing it up for reference)

@deanm0000
Copy link
Collaborator

@ion-elgreco that doesn't work for me. I still get all ints.

@avimallu
Copy link
Contributor

avimallu commented Jun 22, 2023

My output is a little different - it does get cast to float, but after first reading as an integer, it seems:

>>> import polars as pl
>>> pl.Series([[1,2],[2.6,3],[3,4,4.4]], dtype=pl.List(pl.Float32)) 
shape: (3,)
Series: '' [list[f32]]
[
        [1.0, 2.0]
        [2.0, 3.0]
        [3.0, 4.0, 4.0]
]
>>> pl.__version__
'0.18.1'

I would say it's a bug.

@ion-elgreco
Copy link
Contributor

@ion-elgreco that doesn't work for me. I still get all ints.

My bad, I glanced over the printed result. Indeed, it's returning still integers, as @avimallu also shows.

@SujeetO
Copy link
Author

SujeetO commented Jun 23, 2023

how to convert label of this issue to bug from question?

@MarcoGorelli MarcoGorelli added bug Something isn't working and removed question labels Jun 23, 2023
@MarcoGorelli MarcoGorelli changed the title creating polars series with mixed datatype Constructing Series with dtype pl.List(pl.Float32) rounds inputs to integers Jun 23, 2023
@Wainberg
Copy link
Contributor

Duplicate of #11009, which has now been accepted.

@stinodego stinodego added the needs triage Awaiting prioritization by a maintainer label Jan 13, 2024
@stinodego
Copy link
Member

Closing in favor of #11156

@stinodego stinodego closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2024
@stinodego stinodego added python Related to Python Polars and removed needs triage Awaiting prioritization by a maintainer labels Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

7 participants