Machine Learning - What’s in a column?
Machine Learning - What's in a Column? 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] My code so far Import pandas as pd df = pd.read_csv("/usercode/files/one.csv") arr = df[['a', 'b']].values print(arr.shape) filename = input() column_name = input()
7/6/2020 8:30:01 PM
Jovani Velasco
19 Answers
New Answerfilename = input() column_name = input() import pandas as pd import numpy as np df = pd.read_csv(filename) # read the file as a pandas dataframe arr = np.array(df[column_name]) # transform the pretended column as a numpy array print(arr) # show the value of the array better way to understand how to do it ;)
import pandas as pd import numpy as np filename = input() column_name = input() fl= pd.read_csv(filename) print (fl[column_name].values)
Hay hay what had you did this the pro challenges. You can't post them in public . Posting pro challenges! I dont think it's fair. this might help you \/ import pandas as pd import numpy as np filename = input() column_name = input() a=pd.read_csv(filename) b=a[column_name] print(np.array(b)) your code seems very unlogical because taking input after doing all operations.!
Who can tell what's in test ceses 3 - 5 ??? I've passed 1 and 2, but hard to guess farther if you don't know what's being checked.
import pandas as pd filename = input() column_name = input() df = pd.read_csv(filename) print(df[column_name].values) i did mine like this and it worked perfectly. Read the file assigned by the user to the filename and print the value of the character assigned to the column name
solved import pandas as pd import numpy as np filename = input() x= pd.read_csv(filename) column_name = input() d=x[column_name].values print(np.array(d))
this will covers all cases: import pandas as pd import numpy as np filename = input() x= pd.read_csv(filename) column_name = input() d=x[column_name].values print(np.array(d))
import pandas as pd import numpy as np filename = input() column_name = input() fl= pd.read_csv(filename) print (fl[column_name].values)
import pandas as pd df = pd.read_csv('https://sololearn.com/uploads/files/one.csv') arr = df[['a', 'b']].values print(arr[:,0])
I'm having a problem with the same task. If I run my code on Jupiter it works perfectly. However, on the python editor on sololearn, it is not working. Here is my code: import pandas as pd df = pd.read_csv('https://sololearn.com/uploads/files/one.csv') col = df['a'].values col2 = df['b'].values print(col) print(col2) Error: urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution> Anybody, please help. Thank you.
import pandas as pd filename = input() column_name = input() df = pd.read_csv(filename) print(df[column_name].values)
the answer is import pandas as pd import numpy as np filename = input() column_name = input() fl= pd.read_csv(filename) print (fl[column_name].values)
filename = input() column_name = input() import pandas as pd import numpy as np df = pd.read_csv(filename) # read the file as a pandas dataframe arr = np.array(df[column_name]) # transform the pretended column as a numpy array print(arr) # show the value of the array
import pandas as pd import numpy as np filename = input() column_name = input() fl= pd.read_csv(filename) print (fl[column_name].values) #This code is right😀
filename = input() column_name = input() import pandas as pd #use pandas to read the csv file import numpy as np# use numpy for converting the column entries into numpy array data= pd.read_csv(filename) a= data[column_name].values print(np.array(a))
filename = input() column_name = input() import pandas as pd df = pd.read_csv(filename) print(df[column_name].values)
Machine Learning - What's in a Column? 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]
Question is when we input a column name then values will be come from column name #include pandas import pandas as pd #import numpy as np--- not need here we change pandas to numpy use by values keyword file_name = input() #declartion for filename df= pd.read_csv(file_name) #mention above file name here!!!!read the file as a pandas dataframe column_name = input() #column name decalration output=df[column_name].values #mention here above coumn name print(output)