Pandas dataframe frustrations

Why are dataframes so complicated in pandas?   If I have a dataframe:

>>> h.head()
Num_Reads  Tag_Count
0          1     179257
1          2      25025
2          3       6629
3          4       2510
4          5       1192

Then in order to access the first row it’s:

>>>h.iloc[[0]]

Num_Reads  Tag_Count
0         1      179257

Why can’t I just use h[0] instead of this iloc thing?  What advantage does that actually give me?  And for some reason I can’t use h.iloc[[1]][0] to access the first column, I have to use h.iloc[[1]][“Num_Reads”].  It’s like pandas can’t understand that Num_Reads is the first column.  Why can’t I have my array indexing and my key indexing like I can with many other languages??  I understand that if I want multiple columns then I need to provide a list of the columns that I want, but there’s no reason why the pandas code can’t be smart enough to determine if I want a single column matching what I selected or a list of columns.

Leave a comment