I am using Python with Pandas. How can I multiply a column by 1000 given another column has a certain string?
Asked
Active
Viewed 1.2k times
2
-
Possible duplicate of [Pandas conditional creation of a series/dataframe column](https://stackoverflow.com/questions/19913659/pandas-conditional-creation-of-a-series-dataframe-column) – rafaelc Feb 08 '19 at 16:28
1 Answers
14
This should do it.
df['columnname'] = np.where(df['othercolumn'] == 'CertainString',
df['columnname'] * 1000,
df['columnname'])

Nathan Hellinga
- 355
- 3
- 6