Skip to content

DOC: CoW and column addition #57432

@JB-AM

Description

@JB-AM

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/getting_started/intro_tutorials/05_add_columns.html

Documentation problem

I’m still grasping at the CoW error message and how to replace the usefull df['newcolumn'] = process(df['existing_column']), as the error message sends to a not so usefull help page (See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy, may need a separate ticket, but a simple example using a single index would definitely have helped me. The MultiIndex example clearly hides the message behind unnecessary complexity).
But the above mentioned help page (https://pandas.pydata.org/docs/getting_started/intro_tutorials/05_add_columns.html) does not seem to follow the "new good practices" and should probably be updated.

Suggested fix for documentation

I’m not used enough to the new "standard", but the:
air_quality["london_mg_per_cubic"] = air_quality["station_london"] * 1.882
should probably resemble something like:
air_quality[:, "london_mg_per_cubic"] = air_quality["station_london"] * 1.882
and the same for the second example.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions