Reputation: 11
I've got a pandas dataframe:
A.loc[:,:,location]
with location = (x, y)
with x
and y
numbers. When i try to select the columns:
locations = (1, 2)
in:
B = A.loc[:,:,location]
It says: '[(1, 2)] is not in the columns.' When i print the dataframe it clearly says that (1, 2) is in the minor axis. Any idea how I can select these coördinate-like columns?
Upvotes: 0
Views: 1943
Reputation: 2296
It is not really clear what you want, at least to me, but maybe these could help:
# Select the first 3 columns
df.iloc[:,:3]
# Select the first cell down in the column named location
df.ix[0, 'location']
# Select all the location rows has the value of "(1,2)"
df[(df['location'] == '(1,2)')]
Upvotes: 0