I am importing data from a csv file, I want to split the column 'topThemes' into an array/dataframe with two columns.
In the first column I want to have the name of the theme (e.g. Biology), in the second column I want its associated score (e.g. 62).
When I import the column it is stored in this format:
Biology: 62\n
Economics: 12\n
Physics: 4\n
Chemistry: 8\n
and so on.
My current code and the error is shown below.
Code:
df = pd.read_csv(r'myfilelocation')
split = [line.split(': ') for line in df['topThemes'].split('\n')]
Error:
AttributeError("'Series' object has no attribute 'split'")
CSV file being imported:
How I want it to look:
Thanks for any help / responses.