here I have a pandas Dataframe df like:
A B C
0 1 2 3
1 1 2 3
3 1 2 3
Then I have a list
x=['B','C']
I want to get the sum of each number of each row under B & C columns. So I write like:
df[x].sum(axis=1).values
However, I get an error
TypeError: f() got an unexpected keyword argument 'axis'
I don't understand why this will give an error. My code is run in ipython notebook. Could you give any suggestions? Thanks.
UPDATE: the real df is like:
Date Ayotte Hassan
Date
2016-06-29 2016-06-29 46.8 45.3
2016-06-30 2016-06-30 46.8 45.3
2016-07-01 2016-07-01 46.8 45.3
2016-07-02 2016-07-02 46.8 45.3
2016-07-03 2016-07-03 46.8 45.3
2016-07-04 2016-07-04 46.8 45.3
2016-07-20 2016-07-20 45.8 45.2
2016-07-21 2016-07-21 45.8 45.2
2016-07-22 2016-07-22 45.8 45.2
... ... ... ...
2016-10-09 2016-10-09 48.0 44.5
2016-10-10 2016-10-10 48.0 44.5
2016-10-11 2016-10-11 46.7 44.7
2016-10-16 2016-10-16 46.3 44.0
2016-10-17 2016-10-17 46.3 44.0
2016-10-18 2016-10-18 46.0 44.3
2016-10-19 2016-10-19 45.7 45.3
2016-10-20 2016-10-20 44.0 46.0
2016-10-21 2016-10-21 44.0 46.0
2016-10-22 2016-10-22 44.0 46.0
2016-10-23 2016-10-23 44.0 46.0
The dtypes of df is
Date datetime64[ns]
Ayotte float64
Hassan float64
dtype: object
Then, I did
df = df.resample('D')
The df shown above is the data before resample. The list x is
x=['Ayotte','Hassan']
Then the error comes when I run this code
print df[x].sum(axis=1).values
.valuesis the issue Edit, I take that back....It works either way for me.values, but still get the same error.