1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How do I find the mode of a column of categorical data?

Discussão em 'Python' iniciado por Stack, Setembro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I want to find the most repetitive value (which is the mode) of a column of categorical data and fill the blank cells with this value.

    "Embarked" column has only three values: S,Q,C

    When I try to calculate mean and median it gives an error already, because its no numerical value, but I can take a mode of this column, when I try this part of code it doesn't give an error:

    embarked=df_missing['Embarked']
    df_missing['Embarked']=df_missing['Embarked'].fillna(embarked.mode())


    But it also doesn't fill the empty cells. How can I find the mode of this column.

    Continue reading...

Compartilhe esta Página