将类型(字符串)转换为 pandas.core.series.Series

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40837724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 02:31:33  来源:igfitidea点击:

Convert type(String) to pandas.core.series.Series

pythonpython-2.7python-3.xpandas

提问by Shubham R

I have a string say

我有一个字符串说

type(abc)
>>str

i want to convert it into pandas.core.series.Series.

我想把它转换成pandas.core.series.Series。

i came across in pandas documentation that there is a code

我在 Pandas 文档中发现有一个代码

pd.to_string()

which converts pandas series to string, but i want the opposit of it. is there any function/code to do it?

它将Pandas系列转换为字符串,但我想要它的对立面。有什么功能/代码可以做到吗?

回答by Vivek Kalyanarangan

This is a 2.7 implementation for casting a string to a series -

这是用于将字符串转换为系列的 2.7 实现 -

>>> abc = 'some string'
>>> import pandas as pd
>>> abc_series = pd.Series(abc)
>>> print type(abc_series)

Output

输出

<class 'pandas.core.series.Series'>
>>>