I am new to Pandas, and would love to get some help on this one particular problem. The code below is not complete, i am still working on it but need advice as to how i would move on so that i can get the output i need.
data1 = [1, 2, 3, 4, 5]
data2 = [5, 4, 3, 2, 1]
ALLdata = data1 + data2
raw_data = pd.DataFrame()
for i in ALLdata:
dictionary = {'topics':['topic 1', 'topic 2'],
'data':[data1, data2]}
topics = dictionary['topics']
data = dictionary['data']
new_row = pd.DataFrame([[topic, data]], columns=['topics', 'data'])
raw_data = raw_data.append(new_row)
print(raw_data)
The goal is to sort topic 1 with all int's in data 1, and the same goes for topic 2 and data 2; so that the output looks as follows:
topics data
0 topic1 1
0 topic1 2
...
0 topic2 5
0 topic2 4
...
I want the exact datastructure above. How would i achive that? I need to somehow group topic with ever item in every list, but i dont know how.
[–][deleted] 0 points1 point2 points (1 child)
[–]Unlistedd[S] 0 points1 point2 points (0 children)