Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (45.3k points)

Allow me to ask again this question, as answers found on the forum did not help me so far.

I am trying to convert a column from 'string' into 'numerical' data type.

The column has no missing values and no errors, it comes from a CSV file. For the record, I tried modifying the format type of the column on the CSV file and saving it as a number, but later when importing the CSV file on Azure ML it was coded as a string.

So far, I have tried the following options:

  • 'Execute Python script'. Unfortunately, it does not work. It returns an error when I run the experiment. The Code I entered is:

import pandas as df
def azureml_main (df):
  df.age=pd.to_numeric(df.age,errors=’coerce’)
return df
  • Use 'Edit Metadata' module. Select as Datatype: 'Integer' or 'Floating point' but I keep on getting an error when running the experiment.

Please kindly let me know what your thoughts are.

Thanks for your help.

Josep Maria

P.S: It's the second time I write in this forum. I hope this time it is well formulated. screenshot of 'Execute Python Script' error

1 Answer

0 votes
by (16.8k points)

Just update your python script, as you get dataframe1 automatically as a pandas data frame:

import pandas as pd

def azureml_main(dataframe1 = None, dataframe2 = None):

  dataframe1.age = pd.to_numeric(dataframe1.age, errors="coerce")

  return dataframe1

Browse Categories

...