• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: Pivot dataframe with uneven categories

Resolved: Pivot dataframe with uneven categories

0
By Isaac Tonny on 16/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve Pivot dataframe with uneven categories

Question:

enter image description here
Hello everyone,
I have this dataframe from data I scraped. I wanted to pivot_wider but doing that shifts data down. This might be due to the types column having differents lengths of unique values (eg. price appears 12 times and étage 6 times) but I can’t seem to find a way to do what I want it to do.
enter image description here
In this picture it looks correct but in the column bains/douches the data has shifted down so it’s not correct. If someone could help me out I would really appreciate it. Thanks

Best Answer:

The problem here is that there is no indicator where a new entry begins. Below, I assume that each new “price” row marks the start of a new entry. That way, the missing bathroom appears as such.
Created on 2023-03-09 with reprex v2.0.2

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

Source: Stackoverflow.com

dataframe r
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Use Svelte Component as Slot

26/03/2023

Resolved: Vaadin 14.9 – Redirect on Session Destroy Event

26/03/2023

Resolved: How to separate multiple answers in one column, for multiple columns, by creating extra columns

26/03/2023

Comments are closed.

© 2023 DEVSFIX.COM

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