将Python列表转换为pandas系列(Convert Python list to pandas Series)

系统教程 行业动态 更新时间:2024-06-14 16:59:46
将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) )

更多推荐

本文发布于:2023-04-17 08:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/5ab62dd21c876fd95301b498e6633a2b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   系列   列表   Python   pandas

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!