0
import pandas as pd

months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
index = [0,1,2,3,4,5,6,7,8,9,10]
df = pd.DataFrame(0,index = index,columns = months)

#I want to be able to say add(10 where month = "Jul" and header = 6) and end up with a 10 on x="Jul" and y = 6

I have list of locations and data eg ["A","May",5] so I want the data "Hello" to be added to column "Jan" row 5.

    Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
0     0    0    0    0    0    0    0    0    0    0    0    0
1     0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0

would become

    Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
0     0    0    0    0    0    0    0    0    0    0    0    0
1     0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    A    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0

How can I add to a dataframe with X and Y coordinates?

FOH
  • 13
  • 3

0 Answers0