Since the data is from a CSV file, it is probably a string and you can just remove the curly brackets using slicing:
data['data'] = data['data'].str[1:-1]
The pandas documentation on Working with text data isn't very clear about this, but the Pandas.Series.str
methods support slicing as well as indexing. There is also a Pandas.Series.str.slice()
method that can be used for slicing.
The slice notation is given as [start:stop]
. In your case, the brackets are the first and last characters in the string. To get rid of them, you need to take the slice starting from the second character and ending before the last character. Python uses 0-based indexing, so the start position indicating the second character is 1. Indexing from the end of a sequence is designated using negative numbers with -1 being the last character. Slices include all characters up to (but not including) the stop position, so the stop position to exclude the last character is -1. Putting this together, you need the to take a slice from the second character to the next to last character, which is expressed as [1:-1]
.
For a more detailed description of slicing notation in Python, take a look at this answer: https://stackoverflow.com/a/509295/7517724.