I want to take input of the column name and row name from the user and print the intersection of these as output. Python code used: here rm is a dataframe
Uid=input("Enter user id")
Iid=input("Enter item id:")
print(rm.loc[Uid][Iid])
here Userid is stored in column and Itemid in row
sample dataframe being used:
userID 132560 132561 132564 132572 132583 132584 \
0 U1001 1.111111 1.111111 1.111111 1.111111 1.111111 1.111111
1 U1002 1.400000 1.400000 1.400000 1.400000 1.400000 1.400000
2 U1003 1.615385 1.615385 1.615385 1.615385 1.615385 1.615385
3 U1004 1.875000 1.875000 1.875000 1.875000 1.875000 1.875000
4 U1005 1.333333 1.333333 1.333333 1.333333 1.333333 1.333333
132594 132608 132609 ... 135081 135082 135085 \
0 1.111111 1.111111 1.111111 ... 1.111111 1.111111 0.000000
1 1.400000 1.400000 1.400000 ... 1.400000 1.400000 1.000000
2 1.615385 1.615385 1.615385 ... 1.615385 1.615385 1.615385
3 1.875000 1.875000 1.875000 ... 1.875000 1.875000 1.875000
4 1.333333 1.333333 1.333333 ... 1.333333 1.333333 1.333333
135086 135088 135104 135106 135108 135109 mean
0 1.111111 1.111111 1.111111 1.111111 1.111111 1.111111 1.111111
1 1.400000 1.400000 1.400000 1.000000 1.400000 1.400000 1.400000
2 1.615385 1.615385 1.615385 1.615385 1.615385 1.615385 1.615385
3 1.875000 1.875000 1.875000 2.000000 1.875000 1.875000 1.875000
4 1.333333 1.333333 1.333333 1.333333 1.333333 1.333333 1
I even tried with rm.loc[Uid,Iid]
but,that gives me an error that that given userid is not present when it actually is. Please help me out. :(