I have a dataset that has the following features :
[coord_x, coord_y, coord_z, xdot, ydot, zdot]
epoch sat_id x y z Vx Vy Vz
0 2014-01-01 00:00:00.000 0 -8855.823863 13117.780146 -20728.353233 -0.908303 -3.808436 -2.022083
1 2014-01-01 00:46:43.000 0 -10567.672384 1619.746066 -24451.813271 -0.302590 -4.272617 -0.612796
2 2014-01-01 01:33:26.001 0 -10578.684043 -10180.467460 -24238.280949 0.277435 -4.047522 0.723155
3 2014-01-01 02:20:09.001 0 -9148.251857 -20651.437460 -20720.381279 0.715600 -3.373762 1.722115
4 2014-01-01 03:06:52.002 0 -6719.092336 -28929.061629 -14938.907967 0.992507 -2.519732 2.344703
I defined a function that takes those coordinates and return a tuple as follows:
(a, e, i, w, Om, theta) = cart2kep(coord_x, coord_y, coord_z, xdot, ydot, zdot)
I would like to add a, e, i, w, Om, theta as extra features to the initial dataframe : How can I do it efficiently ? Currently, I am doing it as follows :
out = df.apply(lambda x: cart2kep(x[2], x[3], x[4], x[5], x[6], x[7]), axis = 1)
out = out.apply(pd.Series, index = ['a', 'e', 'i', 'w', 'Om', 'theta'])
df = df.join(out)
It takes too long to execute. Is there a more pythonic way of doing it ?
Thank you in advance