Quantcast
Channel: DaniWeb Solved Topics
Viewing all articles
Browse latest Browse all 587

Name the airline with the most total passengers

$
0
0

hello guys I'm trying to make a code that return the name of the flight that has the most total number of passengers from a file :

Alitalia Rome 180
Alitalia Pisa 82
Germanwings Munich 96
Germanwings Frankfurt 163
NorwegianAir Bergen 202
Wizzair London 184
Wizzair Frankfurt 83
Wizzair Lisbon 198

and the OUTPUT should be this :

Wizzair 465     # because this flight has : 184 + 83 + 198 = 465 passenger  and it's the flight with the most total passenger.

here is the code :

# importing pandas as pd 
import pandas as pd
from collections import counter

# Creating the dataframe 
df = pd.read_csv("airlines.csv")

most_total = 0
counts = 0

for iter, n in enumerate(df.split('\n')):
    most_total += counts + 1
    print(df) 
    print(most_total)

and I got thi error:

ImportError: cannot import name 'counter' from 'collections' (C:\Python\Python38-32\lib\collections\__init__.py)

any idea guys ????


Viewing all articles
Browse latest Browse all 587

Trending Articles