Reputation: 4949
say I have a panda data frame where column one is index.
A B C D
2000-01-01 0.469112 -0.282863 -1.509059 -1.135632
2000-01-02 1.212112 -0.173215 0.119209 -1.044236
2000-01-03 -0.861849 -2.104569 -0.494929 1.071804
Is it possible to print a single data point based on an index? For example say I want only data for 2000-01-03
for column C
?
Would be greatly appreciated if someone can help me with this. Thank you very much.
Upvotes: 2
Views: 5816
Reputation: 17943
Andy's solution will work. Other implementations:
df['C'][2]
df.ix[2]['C']
And in later versions of pandas
df.iloc[2]['C']
Upvotes: 0
Reputation: 375635
You can use loc:
In [11]: df.loc['2000-01-03', 'C']
Out[11]: -0.49492900000000001
Note: this will work whether your index is a string or a DatetimeIndex.
Upvotes: 4