Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 18906

groupby and Multiplying a column by scalar

$
0
0

I wrote this code:

tmp_ml['mode_dur_secs_lb'] = tmp_ml.groupby(['id', 'c_num']).apply(    lambda x: x['mode_duration_secs']*0.9)

table:

idc_nummode_duration_secs
a111620
a12793
a2919
a31616
a31719

TypeError: incompatible index of inserted column with frame index


Viewing all articles
Browse latest Browse all 18906


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>