将Python列表转换为pandas系列(Convert Python list to pandas Series)
将Python的句子列表转换为pd.Series对象的方法是什么?
(pandas Series对象可以使用tolist()方法转换为列表;但是如何进行反向转换?)
What is the method to convert a Python list of strings to a pd.Series object?
(pandas Series objects can be converted to list using tolist() method--but how to do the reverse conversion?)
最满意答案
据我所知,您的列表实际上是一个列表列表
import pandas as pd thelist = [ ['sentence 1'], ['sentence 2'], ['sentence 3'] ] df = pd.Series( (v[0] for v in thelist) )I understand that your list is in fact a list of lists
import pandas as pd thelist = [ ['sentence 1'], ['sentence 2'], ['sentence 3'] ] df = pd.Series( (v[0] for v in thelist) )更多推荐
发布评论