I need to optimize this code part which takes dozens of seconds with a big dataset .
if ((isnan(data["x"][i]))==False):
data["Visibility"][i]=int(data["Visibility"][i][0:2]) # Extract the first two numbers
else:
data["x"][i]=1000 # Replace null values with 1000
Editing: For my dataset, I have string column values and I want to replace them with subsets of same values
Here is an example :
"01 : visibilité horizontale 0.1km" --> 01
"02 : visibilité horizontale 0.2km" --> 02
"03 : visibilité horizontale 0.3km" -- > 03
...