将数据帧转换为快速文本数据格式

convert dataframe to fasttext data format

我想将数据帧转换为 fasttext 格式

我的数据框

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

快速文本格式

__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

我试过了df['label'].apply(lambda x: '__label__' + x).add_suffix(df['text']) 但它没有像我预期的那样工作。我应该如何更改我的代码?

尝试:

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