Issue
I have several GB of CSV files where values in one of the columns look like this:
Which is a consequence of this:
urls.append(re.findall(r'http\S+', hashtags_rem))
...
merger = {'Content': clean, 'AttrURL': urls}
cleandf = pd.DataFrame(merger)
...
df.insert(3, "AssocURL", cleandf['AttrURL'])
It took me a while to generate these files and, looking back, I'd certainly write this part differently, but doing it again is a very time-consuming and simply unnecessary endeavour.
Is there another efficient way to remove [' and '] from this column using pandas or csv?
Solution
You can use pandas.DataFrame.apply
to remove the squared parentheses. It should be something like this:
df.apply(lambda string: string[2:-2])
Answered By - lemon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.