I have a pandas dataFrame with in one of the columns (df['data']
) the following data:
[{'validFrom': '2009-02-16', 'validTo': None, 'country': ['NL', 'BE', 'US'],
'model': ['Free']}]
I tried to extract the different values using regex:
df.['data'].str.extract(r"\'validFrom\': \'(.*?)\',")
When I test this in a online regex tester it works, but when I try it in my script it returns NaN
I basically want to extract the values for all fields (validFrom, validTo, country and model).
Example dataframe, the [..]
equals the above mentioned data.
|----------------|-------------|-------------|------------------|
| code | name | type | data |
|----------------|-------------|-------------|------------------|
| 003 | WMG | other | [..] |
What am I doing wrong?