Osca
Osca

Reputation: 1694

convert dataframe to fasttext data format

I want to convert a dataframe to fasttext format

my dataframe

text                                                             label 
Fan bake vs bake                                                 baking
What's the purpose of a bread box?                               storage-method
Michelin Three Star Restaurant; but if the chef is not there     restaurant

fast text format

__label__baking Fan bake vs bake
__label__storage-method What's the purpose of a bread box?
__label__restaurant Michelin Three Star Restaurant; but if the chef is not there

I tried df['label'].apply(lambda x: '__label__' + x).add_suffix(df['text']) But it doesn't work as I expected. How should I change my code ?

Upvotes: 3

Views: 1260

Answers (1)

Nour-Allah Hussein
Nour-Allah Hussein

Reputation: 1459

Try:

'__label__'+df['label']+' '+df['text']

Upvotes: 6

Related Questions