Reputation: 1
I have a pivot table in Python now as follows:
date 2005-06-30 2005-07-01 2005-07-05 2005-07-06 2005-07-07
permco
5 0.006667 -0.006623 0.003333 -0.003322 0.000000
7 0.012098 -0.008422 0.040548 -0.015534 0.006419
35 -0.059574 -0.027149 0.000000 -0.037209 0.053140
36 0.006897 0.027397 -0.080000 0.000000 0.003623
37 -0.022222 0.020053 -0.019659 0.020053 -0.011796
Here, date is the date index and permco is different companies, I have the stock returns in the table. How can I refer to a row in the table? For example I want to refer to the series:
0.006667 -0.006623 0.003333 -0.003322 0.000000
where permco is 5. However, I tried table.loc[1], table[1], table.loc['permco'=i], etc, nothing works.
Upvotes: 0
Views: 43
Reputation: 3306
In your example, you can either use :
df.loc[name_of_index_or_column]
df.iloc[number_of_index]
Upvotes: 2