Reputation: 77
Command
df_main['Ranking'] = df_main['Porosity']*['Permeability']
gives -
TypeError: can't multiply sequence by non-int of type 'str'
The attacehd picture (https://i.sstatic.net/0Asu3.png) has more information. My code snippet is at https://i.sstatic.net/ehqF5.png)
More info: https://i.sstatic.net/0Asu3.png
Upvotes: 1
Views: 14892
Reputation: 19634
First you need to convert the column type of the two columns to floats (otherwise you cannot multiply them). You can do that as follows:
df_main[['Porosity', 'Permeability']] = df_main[['Porosity', 'Permeability']].astype(float)
Then you can define the new column via multiplication:
df_main['Ranking'] = df_main['Porosity']*df_main['Permeability']
Upvotes: 7