如何在没有索引的情况下从 pandas 系列中提取值
How to extract values from pandas Series without index
当我打印我的数据结构时,我有以下内容:
print(speed_tf)
44.0 -24.4
45.0 -12.2
46.0 -12.2
47.0 -12.2
48.0 -12.2
Name: Speed, dtype: float64
我相信这是一个 pandas 系列但不确定
我根本不想要第一列我只想要
-24.4
-12.2
-12.2
-12.2
-12.2
我试过了speed_tf.reset_index()
index Speed
0 44.0 -24.4
1 45.0 -12.2
2 46.0 -12.2
3 47.0 -12.2
4 48.0 -12.2
我怎样才能得到索引从 0 开始的速度值?
speed_tf.values
应该做你想做的。
只需使用Series.reset_index
and Series.to_frame
:
df = speed_tf.reset_index(drop=True).to_frame()
结果:
# print(df)
Speed
0 -24.4
1 -12.2
2 -12.2
3 -12.2
4 -12.2
当我打印我的数据结构时,我有以下内容:
print(speed_tf)
44.0 -24.4
45.0 -12.2
46.0 -12.2
47.0 -12.2
48.0 -12.2
Name: Speed, dtype: float64
我相信这是一个 pandas 系列但不确定
我根本不想要第一列我只想要
-24.4
-12.2
-12.2
-12.2
-12.2
我试过了speed_tf.reset_index()
index Speed
0 44.0 -24.4
1 45.0 -12.2
2 46.0 -12.2
3 47.0 -12.2
4 48.0 -12.2
我怎样才能得到索引从 0 开始的速度值?
speed_tf.values
应该做你想做的。
只需使用Series.reset_index
and Series.to_frame
:
df = speed_tf.reset_index(drop=True).to_frame()
结果:
# print(df)
Speed
0 -24.4
1 -12.2
2 -12.2
3 -12.2
4 -12.2