Jun-22-2019, 03:23 PM
Hello,
I have loaded a dataframe in tsv format with pandas with:
Thank you.
I have loaded a dataframe in tsv format with pandas with:
import numpy as np import pandas as pd df = pd.read_csv(<file>, delimiter='\t')Now I would like to modify the rows of a column based on the condition of another column. This should be pretty simple but I can't find a clear syntax and I am keeping getting errors:
Y.loc[Y.agrmt == 0, 'cons'] = -1 ~.local/lib/python3.6/site-packages/pandas/core/indexing.py:190: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self._setitem_with_indexer(indexer, value) __main__:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy Y.loc[Y.agrmt == 0, ['cons']] = 0 ~.local/lib/python3.6/site-packages/pandas/core/indexing.py:190: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self._setitem_with_indexer(indexer, value) __main__:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copyIs there a simple way to modify the rows of a column based on the values of another?
Thank you.