So I have a data set with over 500 rows where one of the columns has values like this:
df:
column1
0 a{'...'}
1 b{'...'}
2 c{'...'}
3 d{'...'}
I want to remove everything within and including the {}
.
I have been looking at this question, Pandas delete parts of string after specified character inside a dataframe and tried the solutions there but I keep getting errors(And I am aware that StringIO
is now io.StringIO
).
I've tried
df.column1 = df.column1.str.split('{')[0]
but get the error message: KeyError: 0
and don't really understand what that means
I've also tried:
df.column1 = df.column1.str.split(pat='{')
But this only seems deletes the '{' so I'm left with
column1
0 a'...'}
1 b'...'}
2 c'...'}
3 d'...'}
Also I'm not sure if it's important but the column is an object
type.
Can anyone tell me what I'm doing wrong and how to fix the issue???