I have a data frame with a column for number of reviews the dataframe column is listed in this format
816 ratings
1,139 ratings
5 ratings
22,3456 ratings
Id like to convert this to an integer so I can sort the dataframe. My output should be
816
1139
5
223456
I tried
df=df['num_reviews'].str.extract('(\d+)').astype(float)
df
however this converted everything after the comma into a decimal. (i.e. 22,3456 returns 22.0) and using .astype(int) gave me errors due to fields having NaN
df=df['num_reviews'].str.replace(r'\D+', '').astype(int)?.astype(int)float returns decimal values