-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API/BUG: type of scalar aggregations #15385
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
Comments
yes this would be good to make consistent. scalars should always be python scalars; numpy scalars are a weird hybrid that can have odd effects. |
Extra test case from #19381 import pandas as pd
import json
import datetime
data = [
datetime.date(1987, 2, 12),
datetime.date(1987, 2, 12),
datetime.date(1987, 2, 12),
None,
None,
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15),
datetime.date(1989, 6, 15)
]
df = pd.DataFrame(columns=['foo'])
df['foo'] = data
ds = df['foo'].describe()
d = ds.to_dict()
j = json.dumps(d)
print(j) |
This is still an issue and leads to troubles, as the original poster described, in serialization when packages are used which do not know how to handle numpy types. |
@torlenor pull requests for tests and patches are always welcome and how things get fixed |
Currently there is some inconsistency around the scalar type returned from a
Series
aggregation, both in terms of whether it is a numpy or python type, as well as different behavior for an emptySeries
- see table below.Normally this isn't a big deal as the numpy types mostly behave like the python type, but can be an issue with serialization, which is where I ran into this.
Is the desired behavior to make all of these python types?
Code for table
The text was updated successfully, but these errors were encountered: