[Python] Split sentences in pandas into sentence number and words

Discussão em 'Python' iniciado por Stack, Abril 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have a pandas dataframe like this:

    Text start end entity value
    I love apple 7 11 fruit apple
    I ate potato 6 11 vegetable potato


    I have tried to use a for loop It's running slow and I don't think this is what we should do with pandas.

    I want to create another pandas dataframe base on this like:

    Sentence# Word Tag
    1 I Object
    1 love Object
    1 apple fruit
    2 I Object
    2 ate Object
    2 potato vegetable


    Split the text column into words and sentence numbers. Other than the entity word, the other words will be tagged as Object.

    Continue reading...

Compartilhe esta Página