我是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
如何将熊猫系列转换为一个数字?
答案 0 :(得分:2)
如果只想打印序列号,则可以执行以下操作:
x = pd.Series(15)
print(x.values)
print(x.dtype)
输出为
[15]
int64
答案 1 :(得分:1)
使用.values
属性:
x=[3,5,7]
s=pd.Series(x)
s.values
Out[]: array([3, 5, 7], dtype=int64)
它将以Series
数组的形式返回numpy
的值。