将类型(字符串)转换为 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
Convert type(String) to pandas.core.series.Series
提问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'>
>>>