The most advanced ML Observability platform
We’re super excited to share that Aporia is now the first ML observability offering integration to the Databricks Lakehouse Platform. This partnership means that you can now effortlessly automate your data pipelines, monitor, visualize, and explain your ML models in production. Aporia and Databricks: A Match Made in Data Heaven One key benefit of this […]
Start integrating our products and tools.
We’re excited 😁 to share that Forbes has named Aporia a Next Billion-Dollar Company. This recognition comes on the heels of our recent $25 million Series A funding and is a huge testament that Aporia’s mission and the need for trust in AI are more relevant than ever. We are very proud to be listed […]
The loc and iloc methods are used for accessing rows and columns in Pandas DataFrames. In this short how-to article, we will learn how these two methods are different.
Rows and columns have both an index and a label. The difference between the loc and iloc methods are related to how they access rows and columns.
# Second column with loc df.loc[:, "f2"] # Second column with iloc df.iloc[:, 1]
The value before the comma indicates rows to be selected and the one after the comma is for columns. The colon means selecting all.
We can also select particular row and column combinations with these methods.
# Select first row and second column with loc df.loc[0, "f2"] # Select first row and second column with iloc df.iloc[0, 1]
You may have noticed that the index and the label are the same for a row. The reason is that Pandas assigns integer labels to rows unless the labels are explicitly defined.
Both loc and iloc methods can be used to extract a range of row and column combinations.
# Select first two rows and first two columns with loc df.loc[:1, ["f1", "f2"]] # Select first two rows and first two columns with iloc df.iloc[:2, :2]