data analysis EDA issues, indent or type I am a newbie in DS world, right now i am working on some EDA practice, and run into an issue here.

Here is my code:



Convert some columns to numeric values

for column in cols:
    auto[column] = pd.to_numeric(auto[column] 
    return auto

auto = read_auto_data()





error 1:
File "", line 4
return auto
^
SyntaxError: 'return' outside function


I tried to change return's indent:



Convert some columns to numeric values

for column in cols:
    auto[column] = pd.to_numeric(auto[column])
return auto

auto = read_auto_data()





error 2:
TypeError                                 Traceback (most recent call last)
 in ()
  1 ## Convert some columns to numeric values
  2 for column in cols:
----> 3     auto[column] = pd.to_numeric(auto[column])
  4 return auto
  5 


TypeError: 'function' object is not subscriptable

Can anyone help me understand what went wrong here?

Thanks
Try something like this (the function also needs to know what cols is - perhaps pass that in as another parameter?):

def read_auto_data(auto):
    for column in cols:
        auto[column] = pd.to_numeric(auto[column])
    return auto

auto = read_auto_data()