I'm pulling data from google trends and the output values come out as follows:
date value
0 2017-01-01 03:00:00 [65]
1 2017-01-01 03:01:00 [66]
2 2017-01-01 03:02:00 [77]
3 2017-01-01 03:03:00 [64]
4 2017-01-01 03:04:00 [94]
I've trimmed what I don't need. My issue is I need to remove the brackets and make the calue column an int. I've tried the following:
result['value'].apply(lambda x: pd.Series(str(x).replace('[', '').replace(']', '')))
But I get the same output either way. Any thoughts or suggestions?
CodePudding user response:
You can also do:
df['value'] = df['value'].explode()
Output:
date value
0 2017-01-01 03:00:00 65
1 2017-01-01 03:01:00 66
2 2017-01-01 03:02:00 77
3 2017-01-01 03:03:00 64
4 2017-01-01 03:04:00 94
CodePudding user response:
You can do
df['value'] = df['value'].str[0]