how to expand each unique value in another column and fill zero if no match - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: how to expand each unique value in another column and fill zero if no match (/thread-37694.html) |
how to expand each unique value in another column and fill zero if no match - SriRajesh - Jul-10-2022 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 0X 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" |