Python] When converting from Korean column name -> multiindex to English index name, DataFrame cannot find English index name... (DataFrame' object has no attribute 'English index name')

Asked 2 years ago, Updated 2 years ago, 71 views

By "material code"

To see how much of the material has been used over a given period of time,

ex)January 1st to January 31st

Pivot raw data and

pivot_Data = pd.pivot_table (rawData, index = ['material code', 'material details', 'use date'], values = ['quantity'], agfunc = np.sum)

To use value_counts(),

I changed the index name and wrote value_counts() as shown below.

It says there are no codes in the data frame.

pivot_Data.index.names = ['codes', 'title', 'rundate']
pivot_Data.codes.value_counts()

Error history: AttributeError: 'DataFrame' object has no attribute 'codes'

There is also a way to change the column name while preprocessing the data in the CSV file Is there a way to change it while coding?

index multiindex python

2022-09-21 20:06

1 Answers

In other cases, when Rename in DataFrame

df = pd.DataFrame([[ij for ij in i ]for i in rows])
df.rename(columns={0:'ID',1:'DATETIME',2:'TEMP',3:'HUMI'}, inplace=True);
df = df.sort_values(['ID'], ascending=[1]);
df.head()

I changed the name like this and used it.


2022-09-21 20:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.