This question is similar to this one However, when I adapt that solution I receive the following error:
ValueError: cannot reindex from a duplicate axis
I'm trying to do something like this:
import pandas as pd
cols = {'foo': ['A','A','Z','A','Z'], 'bar' : [1,1,1,1,1]}
df = pd.DataFrame(data=cols)
df
bar foo
0 1 A
1 1 A
2 1 Z
3 1 A
4 1 Z
df[df['foo'] == 'Z']['bar'] = df[df['foo'] == 'Z']['bar'] * 100
C:\Anaconda3\envs\Scikit\lib\site-packages\ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy """Entry point for launching an IPython kernel.