[Tutor] Getting started with Pandas

Rafael Knuth rafael.knuth at gmail.com
Wed Aug 22 02:46:11 EDT 2018


import pandas as pd
cities_lst = pd.read_table("cool_cities.csv")
cities_lst.head()

I was trying to rewrite the above as a function.
Unlike my code above, my function below did not return the first 5
rows, but just nothing:

def cities(file_name):
    import pandas as pd
    cities_lst = pd.read_table(file_name)
    cities_lst.head()

cities("cool_cities.csv")

Why does my function not return the first 5 rows?
What's the mistake I am making here?


More information about the Tutor mailing list