Conver column of lists to integer

  bert-language-model, dataframe, pandas, python

Trying to convert after encoding to integers but they are objects so i first turn them into strings

train_df["labels"] = train_df["labels"].astype(str).astype(int)

I am getting this error

invalid literal for int() with base 10: ‘[0, 1, 0, 0]

An example of a row from the dataset is

text                        labels
[word1,word2,word3,word4]    [1,0,1,0]

Source: Python Questions

LEAVE A COMMENT