pandas以类似字典的方式来获取某一列的值,比如df['A'],这会得到df的A列,返回的也是一个Series对象。如果想要获取部分行的话就得用到切片
例如:df'[:3],获取前三行;df[3:4],获取第四行。但是如果想要获取部分行部分列的上述两种方法就无能为力了。这时就得用到 ix, loc, iloc方法(ix已弃用)loc是指location的意思,iloc中的i是指integer。iloc和loc方式索引也更为精细。这两者的区别如下:
loc
works on labels in the index.(说白了就是标签索引)iloc
works on the positions in the index (so it only takes integers). (位置索引,和列表索引类似,里面只能是数字)