Skip to content

Commit

Permalink
MAINT: Silence warning about setting with copy.
Browse files Browse the repository at this point in the history
Pandas raises a warning here because we're assigning to a column of a
subset of a dataframe. This warning is intended to prevent people from
doing things like::

    df[df.col1 > 10]['col1'] = <value>

which has no effect because the first [] creates a copy, which then gets
mutated, so the original frame remains unchanged.

In this case, however, we've bound the copy to a name that we're going to
continue to use, so we don't care about the warning.
  • Loading branch information
Scott Sanderson committed Sep 11, 2018
1 parent 72993a3 commit d809ec1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zipline/assets/asset_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ def _split_symbol_mappings(df, exchanges):
end_date.
"""
mappings = df[list(mapping_columns)]
mappings['sid'] = mappings.index
with pd.option_context('mode.chained_assignment', None):
mappings['sid'] = mappings.index
mappings.reset_index(drop=True, inplace=True)

# take the most recent sid->exchange mapping based on end date
Expand Down

0 comments on commit d809ec1

Please sign in to comment.