I have a problem with the type of one of my column in a pandas dataframe. Basically the column is saved in a csv file as a string, and I wanna use it as a tuple to be able t
You can try this (assuming your csv is called filename.csv):
csv
filename.csv
df = pd.read_csv('filename.csv') df['LABELS'] = df.LABELS.apply(lambda x: x.strip('()').split(',')) >>> df ID LABELS 0 1 [1.0, 2.0, 2.0, 3.0, 3.0, 1.0, 4.0] 1 2 [1.0, 2.0, 2.0, 3.0, 3.0, 1.0, 4.0]