Python Forum
how to expand each unique value in another column and fill zero if no match
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to expand each unique value in another column and fill zero if no match
#1
Hi,
I have below df:

first_name second_name  X     Y      count
A              A1                  0.1   0.4    1
A              A1                  0.2   0.2    2
B              B1                  0.1   0.1    2
B              B1                  0.2   0.2    5


[python]desired output:

first_name  second_name  X     Y      count
A              A1                  0.1   0.4    1
A              A1                  0.2   0.2    2
A              A1                  0.1   0.1    0
B              B1                  0.1   0.1    2
B              B1                  0.2   0.2    5
B              B1                  0.1   0.4    0
X Y
0.1 0.4 this combination exists in A & A1 but not in B& B1. This combination will extend to B & B1 and count is "0"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Make unique id in vectorized way based on text data column with similarity scoring ill8 0 883 Dec-12-2022, 03:22 AM
Last Post: ill8
  pandas: Compute the % of the unique values in a column JaneTan 1 1,775 Oct-25-2021, 07:55 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020