## Trying to find Total Sales & Total Cost of 3 different Countries cars

Problem Description:

Update: Below is the excel file link.

I am brand new to Python and was doing this graph but I am stuck, I am trying to show a horizontal bar graph with 3 different countries, spain, germany, switzerland and trying to show the the total sales and total costs. I keep getting an error but not sure If my formula is correct If you could please take a look.

Error I get is below. If someone could please assist!

line 33

total.plot(‘CountryMake’, [‘Total Sales Price’, ‘Total Cost Price’], kind=’barh’)

^

SyntaxError: invalid syntax

```
import pandas as pd
sales= pd.read_excel('Simplified Car Sales Data.xlsx')
spa= sales[sales['CountryName'] == 'Spain']
spa_totals = spa.sum(axis=0, numeric_only = True)
spa_count = spa.count(axis=0)
spa_total_sale_price = round(spa_totals) ['SalePrice']
spa_total_cost_price = round(spa_totals) ['CostPrice']
swi= sales[sales['CountryName'] == 'Switzerland']
swi_totals = spa.sum(axis=0, numeric_only = True)
swi_count = spa.count(axis=0)
swi_total_sale_price = round(swi_totals) ['SalePrice']
swi_total_cost_price = round(swi_totals) ['CostPrice']
ger= sales[sales['CountryName'] == 'Germany']
ger_totals = ger.sum(axis=0, numeric_only = True)
ger_count = ger.count(axis=0)
ger_total_sale_price = round(ger_totals) ['SalePrice']
ger_total_cost_price = round(ger_totals) ['CostPrice']
totals = pd.DataFrame([('Spain',spa_tot_sale_price, spa_tot_cost_price),
('Switzerland', swi_tot_sale_price,swi_tot_cost_price),
('Germany', ger_tot_sale_price,ger_tot_cost_price),
columns ['CountryName', 'Total Sales Price', 'Total Cost Price']
total.plot('CountryMake', ['Total Sales Price', 'Total Cost Price'], kind='barh')
Error I get is below. If someone could please assist!
File "C:UsersdanacAppDataLocalTempipykernel_166162535154149.py", line 33
total.plot('CountryMake', ['Total Sales Price', 'Total Cost Price'], kind='barh')
^
SyntaxError: invalid syntax
```

## Solution – 1

I don’t think that you defined `total`

in this part of the code. So, you may need to do `totals.plot`

. You also didn’t close the brackets.

```
import pandas as pd
import matplotlib.pyplot as plt
sales= pd.read_excel('Simplified Car Sales Data.xlsx')
spa= sales[sales['CountryName'] == 'Spain']
spa_totals = spa.sum(axis=0, numeric_only = True)
spa_count = spa.count(axis=0)
spa_total_sale_price = round(spa_totals) ['SalePrice']
spa_total_cost_price = round(spa_totals) ['CostPrice']
swi= sales[sales['CountryName'] == 'Switzerland']
swi_totals = spa.sum(axis=0, numeric_only = True)
swi_count = spa.count(axis=0)
swi_total_sale_price = round(swi_totals) ['SalePrice']
swi_total_cost_price = round(swi_totals) ['CostPrice']
ger= sales[sales['CountryName'] == 'Germany']
ger_totals = ger.sum(axis=0, numeric_only = True)
ger_count = ger.count(axis=0)
ger_total_sale_price = round(ger_totals) ['SalePrice']
ger_total_cost_price = round(ger_totals) ['CostPrice']
totals = pd.DataFrame([('Spain',spa_total_sale_price, spa_total_cost_price),
('Switzerland', swi_total_sale_price,swi_total_cost_price),
('Germany', ger_total_sale_price,ger_total_cost_price)],
columns=['CountryName', 'Total Sales Price', 'Total Cost Price'])
totals.plot('CountryName', ['Total Sales Price', 'Total Cost Price'], kind='barh')
plt.show()
```

This should work, although I don’t guarantee given that I don’t have your data.

P.S.

Try to use IDEs. It will be easier that way