1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Parse the column value and save the first section in new column

Discussão em 'Python' iniciado por Stack, Outubro 25, 2024 às 10:22.

  1. Stack

    Stack Membro Participativo

    I need to parse column values in a data frame and save the first parsed section in a new column if it has a parsing delimiter like "-" if not leave it empty

    raw_data = {'name': ['Willard Morris', 'Al Jennings', 'Omar Mullins', 'Spencer McDaniel'],
    'code': ['01-02-11-55-00115','11-02-11-55-00445','test', '31-0t-11-55-00115'],
    'favorite_color': ['blue', 'blue', 'yellow', 'green'],
    'grade': [88, 92, 95, 70]}
    df = pd.DataFrame(raw_data)
    df.head()


    adding a new column that has the first parsed section and the expected column values are : 01 11 null 31

    Continue reading...

Compartilhe esta Página