Clean up construction of Series with dictionary and datetime index
closes #14894 Fix usage of fast_multiget with index which was always throwing an exception that was then caught; add ASV that show slight improvement Author: Nate Yoder <nate@whistle.com> Closes #14895 from nateyoder/series_dict_index and squashes the following commits:56be091
[Nate Yoder] Update whatsnew and fix pep8 issue5f05fdc
[Nate Yoder] Fix usage of fast_multiget with index which was always throwing an exception that was then caught; add ASV that show slight improvement (cherry picked from commite503d40ace
)
This commit is contained in:
parent
bbb76869e7
commit
21ebc0fa54
|
@ -8,13 +8,28 @@ class series_constructor_no_data_datetime_index(object):
|
|||
self.dr = pd.date_range(
|
||||
start=datetime(2015,10,26),
|
||||
end=datetime(2016,1,1),
|
||||
freq='10s'
|
||||
) # ~500k long
|
||||
freq='50s'
|
||||
) # ~100k long
|
||||
|
||||
def time_series_constructor_no_data_datetime_index(self):
|
||||
Series(data=None, index=self.dr)
|
||||
|
||||
|
||||
class series_constructor_dict_data_datetime_index(object):
|
||||
goal_time = 0.2
|
||||
|
||||
def setup(self):
|
||||
self.dr = pd.date_range(
|
||||
start=datetime(2015, 10, 26),
|
||||
end=datetime(2016, 1, 1),
|
||||
freq='50s'
|
||||
) # ~100k long
|
||||
self.data = {d: v for d, v in zip(self.dr, range(len(self.dr)))}
|
||||
|
||||
def time_series_constructor_no_data_datetime_index(self):
|
||||
Series(data=self.data, index=self.dr)
|
||||
|
||||
|
||||
class series_isin_int64(object):
|
||||
goal_time = 0.2
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ Performance Improvements
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- Improved performance of ``.replace()`` (:issue:`12745`)
|
||||
- Improved performance ``Series`` creation with a datetime index and dictionary data (:issue:`14894`)
|
||||
|
||||
|
||||
.. _whatsnew_0192.enhancements.other:
|
||||
|
|
|
@ -187,7 +187,8 @@ class Series(base.IndexOpsMixin, strings.StringAccessorMixin,
|
|||
if len(data):
|
||||
# coerce back to datetime objects for lookup
|
||||
data = _dict_compat(data)
|
||||
data = lib.fast_multiget(data, index.astype('O'),
|
||||
data = lib.fast_multiget(data,
|
||||
index.asobject.values,
|
||||
default=np.nan)
|
||||
else:
|
||||
data = np.nan
|
||||
|
|
Loading…
Reference in New Issue