0
Getting numpy array from dataframe
Getting a column from a numpy array. Task Given a csv file and a column name, print the elements in the given column. Input Format First line: filename of a csv file Second line: column name Output Format Numpy array Sample Input https://sololearn.com/uploads/files/one.csv a File one.csv contents: a,b 1,3 2,4 Sample Output [1 2]
4 Respostas
0
You can learn about pandas to deal with csv files and numpy for multidimensional arrays
0
I know basics of pandas and numpy and I have been trying to write the code. But each time there is some error and I am not getting it. I tried many different inputs
0
import pandas as pd
df = pd.read_csv('https://sololearn.com/uploads/files/one.csv')
arr = df[['a', 'b']].values
print(arr[:,0])
i wrote this but not correct. tried different tweaks but still can’t get the corect answer.
i try putting in Code Playground elsewhere it works but not at the End of Module Project
0
filename = input()
column_name = input()
import pandas as pd
df=pd.read_csv(filename)
arr=df[column_name].values
print(arr)
filename and column_name are arguments that user will input and just write those args inside the function u can get the ans