Invoke columns with python data frame special symbols

Asked 1 years ago, Updated 1 years ago, 115 views

The process of preprocessing data in python.

total = pop[(pop.ages=='total') & (pop.state/region == 'USA')]

The age of the population is total Filter if the residential area of the population is USA.

in pop.state/region Read up to state and show the following error:

AttributeError: 'DataFrame' object has no attribute 'state'

I don't think / is recognized as part of the variable name, how do I handle it?

python dataframe filtering

2022-09-22 16:52

1 Answers

according to how the implementation of and what is the prototype of the pop not or may be

.
pop['state/region']

Shouldn't we approach it like this?


2022-09-22 16:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.