-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
COMPAT: map infers all-nan / empty correctly #18491
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18491 +/- ##
=========================================
Coverage ? 91.32%
=========================================
Files ? 163
Lines ? 49791
Branches ? 0
=========================================
Hits ? 45473
Misses ? 4318
Partials ? 0
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18491 +/- ##
==========================================
+ Coverage 91.3% 91.32% +0.02%
==========================================
Files 163 163
Lines 49781 49791 +10
==========================================
+ Hits 45451 45473 +22
+ Misses 4330 4318 -12
Continue to review full report at Codecov.
|
I am not sure I find this special casing a good idea. I would rather keep
Do you have a specific use case for this? (for wanting to be smart?) (also please try to keep PRs with substantial changes open for a bit longer) |
@jorisvandenbossche this is not special casing at all, rather the reverse. We DO try to infer based on the return values. However nan by-definition a case that needs handling. It defaults to all float which is kind of arbitrary. Having this retain the character of the original is pretty reasonable here. [13] is a bug I think. |
Unless I'm misunderstanding, it doesn't look like this fully hits all of the different types of index. Each index that can hold NA should return the same index class with all NA values, right? On master: In [2]: pd.__version__
Out[2]: '0.22.0.dev0+241.gf745e52'
In [3]: pd.date_range('20170101', periods=4).map({})
Out[3]: DatetimeIndex(['NaT', 'NaT', 'NaT', 'NaT'], dtype='datetime64[ns]', freq=None)
In [4]: pd.interval_range(0, 5).map({})
Out[4]: Float64Index([nan, nan, nan, nan, nan], dtype='float64')
In [5]: pd.CategoricalIndex(list('abca')).map({})
Out[5]: Float64Index([nan, nan, nan, nan], dtype='float64')
In [6]: pd.Index(list('abca')).map({})
Out[6]: Float64Index([nan, nan, nan, nan], dtype='float64')
In [7]: pd.period_range('2017Q1', periods=4, freq='Q').map({})
Out[7]: DatetimeIndex(['NaT', 'NaT', 'NaT', 'NaT'], dtype='datetime64[ns]', freq=None)
In [8]: pd.timedelta_range(1, periods=4).map({})
Out[8]: DatetimeIndex(['NaT', 'NaT', 'NaT', 'NaT'], dtype='datetime64[ns]', freq=None) |
xref #18482