You want to create a new data frame after subtracting the value of the even action from the value of the time hole action. Row 1 - Row 0 results to row 0 of the new data frame Row 3 - Row 2 results are made into a row 1 of the new data frame You want to compute up to the last of the rows (8 len(data.Time).
import pandas as pd
import numpy as np
raw_data = {'Time': [281.54385, 436.55295, 441.74910, 528.36445,
974.48405, 980.67895, 986.65435, 1026.02485]}
data = pd.DataFrame(raw_data)
data
Desired Results
It's very difficult because I'm a beginner at playing Pandas. Please teach me a lesson.
pandas
for
It's almost there if you turn the door. Check out the example of js.
https://codepen.io/yuptogun/pen/bjbdrb
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import pandas as pd
>>> raw_data = {'Time': [281.54385, 436.55295, 441.74910, 528.36445,
974.48405, 980.67895, 986.65435, 1026.02485]}
>>> data = pd.DataFrame(raw_data)
>>> data
Time
0 281.54385
1 436.55295
2 441.74910
3 528.36445
4 974.48405
5 980.67895
6 986.65435
7 1026.02485
>>> data_odd = data[1::2]
>>> data_odd
Time
1 436.55295
3 528.36445
5 980.67895
7 1026.02485
>>> data_even = data[::2]
>>> data_even
Time
0 281.54385
2 441.74910
4 974.48405
6 986.65435
>>> data_diff = data_odd.reset_index() - data_even.reset_index()
>>> data_diff
index Time
0 1 155.00910
1 1 86.61535
2 1 6.19490
3 1 39.37050
>>> data_diff = data_diff[['Time']].rename(columns={'Time':'ON_TIME'})
>>> data_diff
ON_TIME
0 155.00910
1 86.61535
2 6.19490
3 39.37050
© 2024 OneMinuteCode. All rights reserved.