Suppose I have Panda DataFrame which looks following:
Input
Name    Key Val
David   A   1
Roe     B   2
John    A   3
Nat     B   4
I want to split by Key and Group by Name.
Output
Name    A   B
David   1   nan
John    3   nan
Nat     nan  4
Roe     nan  2
Can you please suggest a way to do it?
Below is code to generate the dataframe.
import pandas as pd
# Initializing the nested list with Data-set
data = [['David','A',1],
        ['Roe','B',2],
        ['John','A',3],
        ['Nat','B',4]]
df = pd.DataFrame(data, columns=['Name', 'Key','Val'])
 
    