【发布时间】:2021-07-03 16:07:58
【问题描述】:
我对数据框的一部分进行了切片以仅保留两列。
description_category = titles[['listed_in','description']]
摘录是这样的
description_category.head()
Listed_in description
0 International TV Shows, TV Dramas, TV Sci-Fi &... In a future where the elite inhabit an island ...
1 Dramas, International Movies After a devastating earthquake hits Mexico Cit...
2 Horror Movies, International Movies When an army recruit is found dead, his fellow...
3 Action & Adventure, Independent Movies, Sci-Fi... In a postapocalyptic world, rag-doll robots hi...
4 Dramas A brilliant group of students become card-coun...
我想要做的是在“Listed_in”列中放入[,]每个主题,所以它看起来像这样:
listed_in description
0 [International TV Shows, TV Dramas, TV Sci-Fi ... In a future where the elite inhabit an island ...
1 [Dramas, International Movies] After a devastating earthquake hits Mexico Cit...
2 [Horror Movies, International Movies] When an army recruit is found dead, his fellow...
3 [Action & Adventure, Independent Movies, Sci-F... In a postapocalyptic world, rag-doll robots hi...
4 [Dramas] A brilliant group of students become card-coun...
我试过了,但它显示了一个警告:
description_category['listed_in'] = description_category['listed_in'].apply(lambda x: x.split(', '))
警告:
C:\Anaconda\envs\nlp_course\lib\site-packages\ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
"""Entry point for launching an IPython kernel.
我在这个问题上检查了几个线程,但我仍然无法修复它。
你建议我做什么?
如果您需要我的问题的更多背景信息,请告诉我。
【问题讨论】: