I want to convert the following column (part of a DataFrame) into a numeric value.
df = pd.DataFrame({ "Cluster": [[0], [1], [0], [2]]})
My following code didn't work:
pd['Cluster_numeric'] = pd.to_numeric(df['Cluster'], errors='coerce')
This should work considering your length of the list is always 1
df['Cluster_numeric']=df['Cluster'].apply(lambda x: x[0])