python - How can I shift the index of a DataFrame when using Float64Index? -


as question mentions, have pandas (v. 0.18.0) dataframe consists of few columns of 1d data (simulated optical spectra).

a sample dataset looks following:

photon energy (ev),  spin_up (a.u.),  spin_down (a.u.),       difference   1.520040,                  0.000000,           0.00000,         0.000000    1.520515,                  0.000000,           0.00000,         0.000000    1.520990,                  0.000000,           0.00000,         0.000000    1.521465,                  9.742188,           0.00000,         9.742188    1.521940,                 35.432140,          24.41665,        11.015490    1.522415,                 69.708160,          99.48898,       -29.780820    1.522890,                140.897400,         198.71710,       -57.819700    1.523365,                369.593200,         401.61710,       -32.023900    1.523840,               1688.481000,        1034.93300,       653.548000    1.524315,               1822.535000,        4645.04600,     -2822.511000    1.524790,               1284.102000,        5457.34800,     -4173.246000    

the data imported directly csv (pd.read_csv('sample.csv', index_col='photon energy (ev)'), , 3 imported columns index row (photon energy 6 decimal precision) , 2 electron populations (integer values).

now, i'd shift index column ~2.5mev (corresponding 200 rows).

i've pulled max point following:

abs_max = df.loc[1.52:1.53,["sum"]].idxmax() shift_idx = df.index.get_loc(abs_max[0]) shift_amt = int(shift_idx - spdf.index.get_loc(1.515005)) 

then tried apply shift df.shift(periods=shift_amt) (i realize int() on shift_amt unnecessary, trying cover bases). seemed have no effect (index column unshifted). trying apply value freq inside shift() function made no difference. when tried same thing using df.index.shift(), given error notimplementederror: not supported type float64index. assume means i'm trying isn't possible, , should go using simple integer index column. but, before give up, i'd know if there i'm missing in process.

you can change index values this:

df.index += x 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -