Closed milodubois closed 2 years ago
pandas.DataFrame.ix is deprecated as of version 0.20.0, and consequently the following code from https://jakevdp.github.io/PythonDataScienceHandbook/03.11-working-with-time-series.html generates error if alternative is not used (described in second code block).
pandas.DataFrame.ix
0.20.0
incorrect (uses deprecated indexer):
import matplotlib.pyplot as plt fig, ax = plt.subplots(1, 2, figsize=(14, 5)) by_time.ix['Weekday'].plot(ax=ax[0], title='Weekdays', xticks=hourly_ticks, style=[':', '--', '-']) by_time.ix['Weekend'].plot(ax=ax[1], title='Weekends', xticks=hourly_ticks, style=[':', '--', '-']);
correct (uses loc):
loc
import matplotlib.pyplot as plt fig, ax = plt.subplots(1, 2, figsize=(14, 5)) by_time.loc['Weekday'].plot(ax=ax[0], title='Weekdays', xticks=hourly_ticks, style=[':', '--', '-']) by_time.loc['Weekend'].plot(ax=ax[1], title='Weekends', xticks=hourly_ticks, style=[':', '--', '-']);
Kindly, N.B., loc should be used in place of ix. Using the code prefixed by 'correct' will generate the appropriate plot as described in the chapter.
ix
Regards, Milo
Thanks – see https://www.oreilly.com/library/view/python-data-science/9781098121211/; I'll update the notebooks here soon.
pandas.DataFrame.ix
is deprecated as of version0.20.0
, and consequently the following code from https://jakevdp.github.io/PythonDataScienceHandbook/03.11-working-with-time-series.html generates error if alternative is not used (described in second code block).incorrect (uses deprecated indexer):
correct (uses
loc
):Kindly, N.B.,
loc
should be used in place ofix
. Using the code prefixed by 'correct' will generate the appropriate plot as described in the chapter.Regards, Milo