• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Copy a Multi-Index column of a Pandas Dataframe including the second header

Resolved: Copy a Multi-Index column of a Pandas Dataframe including the second header

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Background – I have a dataset with two headers that I’ve read from a CSV…
What I Want – I’d like to duplicate one of the columns (say, A) into a new column D, such that…
What I’m Getting – …but when I do this using df['D'] = df['A'], what I get is a copy without the content of the second header…
TLDR – How can I capture the content of the second header of my multi-index dataframe when copying a column?

Answer:

Need to specify both levels of multiindex
enter image description here

If you have better answer, please add a comment about this, thank you!

dataframe multi-index pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why reference in pointer array doesn’t have data?

24/03/2023

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.