Hello
I’m new to python some 6 weeks in, and working on my project.
I have a trouble creating a new column that would sum two existing ones, that I’ve created form Pivot Tables.
The bale look like this:
size
Timely_Response No Yes
Company
WELLS FARGO & COMPANY 3244.0 67675.0
EQUIFAX, INC. 1627.0 114076.0
BANK OF AMERICA, NATIONAL ASSOCIATION 1585.0 80519.0
OCWEN LOAN SERVICING LLC 542.0 27208.0
Colony Brands, Inc. 419.0 256.0
What I need to do is to add “Total” column that would sum “No” and “Yes” values for each row
and then add “‘No’ % of Total” and then sort by that % column.
I was trying to use sum, but that gave me too large numbers
slow_resolution_sorted["Totals"]=slow_resolution_sorted.sum(axis=1)
size Totals
Timely_Response No Yes
Company
WELLS FARGO & COMPANY 3244.0 67675.0 567352.0
EQUIFAX, INC. 1627.0 114076.0 925624.0
then I was trying to add No and Yes but I got an error.
slow_resolution_sorted["Totals"]=slow_resolution_sorted["No"]+slow_resolution_sorted["Yes"]
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3080 return self._engine.get_loc(casted_key)
3081 except KeyError as err:
→ 3082 raise KeyError(key) from err
3083
3084 if tolerance is not None:
KeyError: ‘No’
Any ideas what I’m doing wrong and how to fix it?
Thanks!