Skip to content

ENH: The method of obtaining a certain cell or slice of the dataframe is confusing and unclear #61232

Open
@zyy37

Description

@zyy37

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

The method of obtaining a certain cell or slice of the dataframe is confusing and unclear, such as using loc, iloc, at, iat, and the operator [], etc. For example, df.loc[row_label, col_label] and df.iloc[row_index, col_index]. If loc is a property, it is better to be a variable but now it is a verb or something rather than a df buffer. The user wants to take the cell value, so the behavior of loc is like a member function and the () operator should be used to pass parameters. However, you are using the operator [], but the object of the operator [] is usually an instance, which is a confusing place.

And when taking two columns or slices at the same time, for example, taking one column and one row, the expression value = df.loc[1, 'B'], where the operator [] represents the horizontal and vertical coordinate information, and taking two columns and one row, row_data = df.loc['row_label', ['col1', 'col2']], where the second operator [] has both vertical coordinate information but behaves like a list or tuple instead of the former, this is another confusing aspect.

In mathematics, the coordinate values such as (3, 4) represent the horizontal and vertical coordinates respectively, as well as the () operator. I hope that the operation rules you define should conform to common customs or competition analysis or benchmarking such as numpy. thank you.

Feature Description

n/a

Alternative Solutions

n/a

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions