Use_iloc
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery rule id: use_iloc
Section titled “Sourcery rule id: use_iloc”Description
Section titled “Description”Use the .iloc attribute for index-based selection
Before
Section titled “Before”df: pandas.DataFramedata = df[1]df: pandas.DataFramedata = df.iloc[1]Explanation
Section titled “Explanation”Using ‘iloc’ is optimized for selecting data in Pandas based on index position (https://pandas.pydata.org/pandas-docs/stable/user_guide/10min.html#selection). This rule replaces the generic indexing with ‘iloc’ for index-based selection.
Before:
Section titled “Before:”data = df[5]After:
Section titled “After:”data = df.iloc[5]