I have a csv like this:
Art Category LEVEL 2 LEVEL 3 LEVEL 4 LEVEL 5 Location
0 PRINTMAKING VISUAL CONTEMPORARY 2D NaN NaN NaN
1 PAINTING VISUAL CONTEMPORARY 2D NaN NaN NaN
2 AERIAL VISUAL CONTEMPORARY 2D PHOTOGRAPHY AERIAL NaN
3 WILDLIFE VISUAL CONTEMPORARY 2D PHOTOGRAPHY WILDLIFE NaN
4 NATURE VISUAL CONTEMPORARY 2D PHOTOGRAPHY NATURE NaN
The art and category will be there but the levels from l1 to l6 can be null. What I want to achive is like so:
art: PRINTMAKING
category: VISUAL
tags: [CONTEMPORARY, 2D]
The levels are basically tags for a particular art which are to stored in an array.
I am new to python and so far I have written the following code. How can I achive this.
import pandas as pd
import json
data = pd.read_excel("C:\\Users\\Desktop\\visual.xlsx")
rec = {}
rec['art'] = data['Art']
rec['category'] = data['Category']
rec['tags'] = data['LEVEL 2'] + ',' + data['LEVEL 3'] + ',' + data['LEVEL 4'] + ',' + data['LEVEL 5']
I guess this is not the correct way to do it.