Mar-27-2018, 04:13 PM
I think there's something rather fundamental I have missed regarding calling functions.
I need to fill a column in one dataframe with the sum of the columns in another dataframe.
First I did something like:
Then instead I did:
BTW: I know 'in range(1,genericreturnperiods+1)' might be non-pythonic, but I need to make it start at 1 not 0 - so 'x in range(genericreturnperiods)' alone wouldn't work.
I need to fill a column in one dataframe with the sum of the columns in another dataframe.
First I did something like:
for x in range(1,genericreturnperiods+1): currentsum = sum(genericresults['%ddaylog' %x])So for each loop i add the sum of another column. This returned 'NaN' for all columns including at least one NaN value.
Then instead I did:
for x in range(1,genericreturnperiods+1): currentsum = genericresults['%ddaylog' %x].sum()This seems to work just fine, or at least I get a sum instead of just NaN. Why would this be?
BTW: I know 'in range(1,genericreturnperiods+1)' might be non-pythonic, but I need to make it start at 1 not 0 - so 'x in range(genericreturnperiods)' alone wouldn't work.