+ 1
Machine Learning - What’s in a column?
by this code I've passed 1 , but how can I improve my code to pass 2and other part of question import pandas as pd df = pd.read_csv('usercode/files/one.csv') arr = df[['a']].values print(arr[:,0])
5 Respostas
+ 1
For the future:
https://code.sololearn.com/W3uiji9X28C1/?ref=app
0
1. For the task you have to take two inputs: one for the filename, one for the column_name. Instead you used the example input.
2. You need only one pair of square brackets in the definition of arr.
3. arr should be a one-dimensional array, so you can print it in it's entirety.
0
1. Nos dan un archivo, por lo tanto debemos leerlo por medio de panda.
2. Convertimos en un array el nombre de la columna dada como segunda entrada usando ".values"
3. imprimimos todo el array
espero ser de ayuda :)
filename = input()
column_name = input()
import pandas as pd
df = pd.read_csv(filename)
arr = df[column_name].values
print(arr[:])
0
1. Nos dan un archivo, por lo tanto debemos leerlo por medio de panda.
2. Convertimos en un array el nombre de la columna dada como segunda entrada usando ".values"
3. imprimimos todo el array
espero ser de ayuda :)
filename = input()
column_name = input()
import pandas as pd
df = pd.read_csv(filename)
arr = df[column_name].values
print(arr[:])
0
Hi Fataneh Tabarteh Farahani
#Just reorganize the code
import pandas as pd #is important to start like this
filename = input() #this was given
column_name = input() #this was given
df = pd.read_csv(filename) #to read the file
arr = df[column_name].values #to get the data and output it as requested
print(arr)