How to multiply all numeric values ββin a data frame by a constant without having to explicitly specify column names? Example:
In [13]: df = pd.DataFrame({'col1': ['A','B','C'], 'col2':[1,2,3], 'col3': [30, 10,20]}) In [14]: df Out[14]: col1 col2 col3 0 A 1 30 1 B 2 10 2 C 3 20
I tried df.multiply , but it also affects string values, concatenating them several times.
In [15]: df.multiply(3) Out[15]: col1 col2 col3 0 AAA 3 90 1 BBB 6 30 2 CCC 9 60
Is there a way to keep string values ββconstant while multiplying only numeric values ββby a constant?
source share