I would like to create a function that extracts a range of rows (n:m) from a dataset (.csv). It should ignore the first row, also, it should convert in integer the "Number Minutes" column.
Our dataset ("file_name.csv") would look like this:
?Name;Age;Team;Number Minutes
Henry Dalton;19;Chelsea FC;1.200
John Smith;50;Manchester Utd.;4.000
Herman Lock;32;Manchester City;2.400
Kyle Hard;23;Everton Football Club;1.200
The function would look like this:
find_player("file_name.csv", 2, 3)
And the outcome would be:
['John Smith' , '50' , 'Manchester Utd.' '4000']
['Herman Lock' , '32' , 'Manchester City' , '2400']
I've chose to use pandas. So far I've made this code:
import pandas as pd
file_route = r'.file_name.csv'
def find_player(file_route, n, m):
data = pd.read.csv(file_route)
data2 = data[n, m].copy()
data2[3] = data2[3].astype(int)
print(data2)
return(data2)
I can't get the correct solution, so I could use some help.
Thanks!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…