Let's say that I have a dataframe, X, initiated with 0s and a dimension m x n. I have n unique values (1,2,3,...,n) in a pandas.series, Y, that has length m. How do I set the Y[i] column of the ith row of X (change 0 to 1) efficiently without using a loop. Especially for large m and n.
For example, for Y = [3,2,1]
X
row     1       2      3
0       0       0      0
1       0       0      0
2       0       0      0
to
row     1       2      3
0       0       0      1
1       0       1      0
2       1       0      0
    
mdoes not necessarily equaln), then it is not helpful to have a square matrix as your example.iatis faster for setting scalar values compared toiloc.