[Tutor] Getting started with Pandas

Giles Coochey giles.coochey at netsecspec.co.uk
Wed Aug 22 06:14:45 EDT 2018



On 22/08/2018 07:46, Rafael Knuth wrote:
> 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()
try "return cities_lst.head()" rather than just "cities_list.head()"

> cities("cool_cities.csv")
>
> Why does my function not return the first 5 rows?
> What's the mistake I am making here?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list