Re: [Tutor] Getting started with Pandas

2018-08-22 Thread Alan Gauld via Tutor
On 22/08/18 11:29, Rafael Knuth wrote: > my code below did not require a return statement, hence I was assuming > it wouldn't be needed in my function either. return is only used inside a function, it makes no sense outside (and is a syntax error). Its purpose is to return a value to the caller o

Re: [Tutor] Getting started with Pandas

2018-08-22 Thread Giles Coochey
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):

Re: [Tutor] Getting started with Pandas

2018-08-22 Thread Rafael Knuth
> You are not returning anything. > You need to use the return keyword otherwise your > function just generates the data internally then > throws it away again. ok, got it - thanks. my code below did not require a return statement, hence I was assuming it wouldn't be needed in my function either.

Re: [Tutor] Getting started with Pandas

2018-08-22 Thread Alan Gauld via Tutor
On 22/08/18 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_

Re: [Tutor] Getting started with Pandas

2018-08-22 Thread Giles Coochey
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):