Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract values from pandas Series without index

I have the following when I print my data structure:

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

I believe this is a pandas Series but not sure

I do not want the first column at all I just want

-24.4
-12.2
-12.2
-12.2
-12.2

I tried 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

How can I just get the Speed values with index starting at 0?

like image 475
wwjdm Avatar asked May 29 '20 13:05

wwjdm


People also ask

How can I access pandas without index?

In case if you wanted to write a pandas DataFrame to a CSV file without Index, use param index=False in to_csv() method.

How do I get pandas series values?

get() function to get the value for the passed index label in the given series object. Output : Now we will use Series. get() function to return the value for the passed index label in the given series object.

How do you extract a value from a series object in Python?

Use pd. Series. Call pd. Series. item() with the extracted row as pd. Series to extract a value.

How do I export a pandas DataFrame to CSV without index?

pandas DataFrame to CSV with no index can be done by using index=False param of to_csv() method. With this, you can specify ignore index while writing/exporting DataFrame to CSV file.


Video Answer


2 Answers

speed_tf.values 

Should do what you want.

like image 54
Igor Rivin Avatar answered Oct 12 '22 09:10

Igor Rivin


Simply use Series.reset_index and Series.to_frame:

df = speed_tf.reset_index(drop=True).to_frame()

Result:

# print(df)

   Speed
0  -24.4
1  -12.2
2  -12.2
3  -12.2
4  -12.2
like image 39
Shubham Sharma Avatar answered Oct 12 '22 10:10

Shubham Sharma