[Python] Trying to implode (numbers type column) to a dataframe in python in AWS [duplicate]

Discussão em 'Python' iniciado por Stack, Fevereiro 13, 2025.

  1. Stack

    Stack Membro Participativo

    Im trying to implode by two groups "Test" and "Name".

    Test Subject Scores
    Test1 Math 75
    Test1 Math 60
    Test1 Math 34
    Test2 History 28
    Test2 History 90
    Test2 History 76
    Test2 History 55
    Test3 English 33
    Test3 English 89
    Test3 English 54

    I wanted to look like this:

    Test Subject Scores
    Test1 Math 75,60,34
    Test2 History 28,90,76,55
    Test3 English 33,89,54

    However I use this code

    Testdf = Test.groupby(['Name', 'Test'])['Score'].apply(
    lambda x: x.tolist()[0]
    ).reset_index()


    And the results only gives me the first score of the list, but not the others.

    Test Name Scores
    Test1 Math 75
    Test2 History 28
    Test3 English 33

    I have tried different variations, it seems to be a problem because they are integers or inside AWS.

    Edit: Code from that folks recommended works on local but not on AWS. Still giving me one data point for scores.

    Continue reading...

Compartilhe esta Página