我对python和jupyter笔记本很陌生。
我想在熊猫系列中搜索(或提取)数字。
例如,我有一个熊猫系列x。
x=pd.Series(15)
print(x)
type(x)
0 15
dtype: int64
pandas.core.series.Series我只想要数字15作为整数
x=15
print(x)
type(x)
15
int如何将熊猫系列转换成一个数字?
发布于 2019-04-15 20:03:25
如果只想打印系列的编号,则可以:
x = pd.Series(15)
print(x.values)
print(x.dtype)输出是
[15]
int64发布于 2019-04-15 20:05:28
使用.values属性:
x=[3,5,7]
s=pd.Series(x)
s.values
Out[]: array([3, 5, 7], dtype=int64)它将将Series的值作为numpy数组返回。
https://stackoverflow.com/questions/55696400
复制相似问题