Answers for "pandas editing multiple values in a row"

3

replace multiple values in pandas column

df = pd.DataFrame({'a':['Small', 'Medium', 'High']})

In [22]: df
Out[22]: 
        a
0   Small
1  Medium
2    High

[3 rows x 1 columns]

df.replace({'a' : { 'Medium' : 2, 'Small' : 1, 'High' : 3 }})
Posted by: Guest on October-05-2020
0

update multiple rows dataframe

df.loc[df.strings.isin(["C", "D", "E"]), df.columns.difference(["strings"])] = 0
df
Out[82]: 
  price strings value
0     1       A     a
1     2       B     b
2     0       C     0
3     0       D     0
4     0       E     0
Posted by: Guest on June-19-2021

Code answers related to "pandas editing multiple values in a row"

Python Answers by Framework

Browse Popular Code Answers by Language