转自:https://blog.csdn.net/qq_21840201/article/details/80725433 ### 随机生DataFrame 类型数据import pandas as pdimport numpy as npframe = pd.DataFrame(np.random.rand(4,4),index=list('abcd'),columns=list('ABCD'))frame A B C Da 0.560094 0.352686 0.954100 0.9262…
loc 从特定的 gets rows (or columns) with particular labels from the index. iloc gets rows (or columns) at particular positions in the index (so it only takes integers). ix usually tries to behave like loc but falls back to behaving like iloc if a label i…
loc: only work on indexiloc: work on positionix: You can get data from dataframe without it being in the indexat: get scalar values. It's a very fast lociat: Get scalar values. It's a very fast iloc…
先看代码: In [46]: import pandas as pd In [47]: data = [[1,2,3],[4,5,6]] In [48]: index = [0,1] In [49]: columns=['a','b','c'] In [50]: df = pd.DataFrame(data=data, index=index, columns=columns) In [51]: df Out[51]: a b c 0 1 2 3 1 4 5 6 1. loc--通过行标签索引行…