I can sum the first 310 rows in a 5 column pandas dataframe and get a tidy summary by using:
df.[0:310].sum
Is there an easy way whereby I can sum the first 310 rows in a certain column of my choosing? I just can't figure out how to combine a column selection and row slice selection in the expression. It would be ideal to specify the column by column name, but column index is fine too.
In an attempt to sum the 1st 310 rows of the 5th column, I tried
df.iloc[0:310, 4].sum
but just got a printout of 310 rows from that column. Thank you.