I have data as below
user  region  attribute   reading
Jon   Europe  fathername  peter
Jon   Europe  age         50
Jon   Europe  mothername  mary
Jon   Europe  age         44
Jon   Europe  brothername duke
Jon   Europe  age         25
This is how it is stored in sql database. I am reading this into a dataframe and trying to generate the data as below
attribute             fathername age mothername age brothername age     
User      region
Don       Europe      peter      50   mary      44  duke         25
However, I am unable to get this
The age does not repeat and appears only once and takes any one of those values
This is what I have tried -
pd.pivot_table(df_mysql , index=['User'],columns=['attribute'],values=['reading'], aggfunc=lambda x: x,dropna = 'False')
Repeated attribute(column ) must appear. May I have any ideas on this please
 
    