I've been getting runtime warnings for a piece of code from urbansim.urbanchoice that we use to sample alternatives for an estimation dataset.
I think what's happening is that the runtime environment does not recognize the output of df.take() as an explicit copy (even though my reading of the documentation is that it should be), so it sees this as potential chained indexing:
Coverage remained the same at 52.805% when pulling f94f920c318b2a7ee7bf90bb55d4c61026131166 on setting-with-copy into 1ecfb4d1ec1a7c48045918048dd1d6f2087b5ea9 on master.
I've been getting runtime warnings for a piece of code from
urbansim.urbanchoice
that we use to sample alternatives for an estimation dataset.I think what's happening is that the runtime environment does not recognize the output of
df.take()
as an explicit copy (even though my reading of the documentation is that it should be), so it sees this as potential chained indexing:http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.take.html
Neither of these changes resolved the warning:
alts_sample.loc[:,'join_index'] = ...
alts_sample = alternatives.take(sample, is_copy=True)
But this did:
alts_sample = alternatives.take(sample).copy()
This PR also clears the warning from two notebooks (results remained the same).