0

This is the dataframe that I am using.

     Product  January  February  March  April  May  June
 NR-DZ600MB       10        10     10     10   10    10
NR-F654GT-XG      10        10     10     10   10    10
NU-SC300BYPQ      10        10     10     10   10    10
NU-SC180BYPQ      10        10     10     10   10    10
   SR-JQ105       10        10     10     10   10    10
  

The output I want to get is this

{('January', 'NR-DZ600MB'): 10, ('January', 'NR-F654GT-XG'): 10, ('January', 'NU-SC300BYPQ'): 10, ('January', 'NU-SC180BYPQ'): 10, ('February', 'NR-DZ600MB'): 15, ('February', 'NR-F654GT-XG'): 20, ('February', 'NU-SC300BYPQ'): 10, ('February', 'NU-SC180BYPQ'): 10, ('March', 'NR-DZ600MB'): 10, ('March', 'NR-F654GT-XG'): 10, ('March', 'NU-SC300BYPQ'): 10, ('March', 'NU-SC180BYPQ'): 10....}

How am I suppose to do it?

Jace123123
  • 11
  • 4
  • Does this answer your question? https://stackoverflow.com/questions/26716616/convert-a-pandas-dataframe-to-a-dictionary – PApostol Nov 22 '20 at 13:07
  • Does this answer your question? [Convert a Pandas DataFrame to a dictionary](https://stackoverflow.com/questions/26716616/convert-a-pandas-dataframe-to-a-dictionary) – PApostol Nov 22 '20 at 13:07

1 Answers1

0
data = {'Product':['NR-DZ600MB', 'NR-F654GT-XG', 'NU-SC300BYPQ', 'NU-SC180BYPQ', 'SR-JQ105'], 
         'January':[10,10,10,10,10], 'February':[10,10,10,10,10], 'March':[10,10,10,10,10],
         'April':[10,10,10,10,10], 'May':[10,10,10,10,10], 'June':[10,10,10,10,10]}

df = pd.DataFrame(data)

array = {}
for i in range(1,(df.shape[1])):
    for j in range(df.shape[0]): 
        col = df.columns[i]
        array[df.columns[i],df['Product'][j]] = df[col][j]
    
print(array)