- 4
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()
25 ответов
+ 26
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
better way to understand how to do it ;)
+ 15
import pandas as pd
import numpy as np
filename = input()
column_name = input()
fl= pd.read_csv(filename)
print (fl[column_name].values)
+ 5
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.!
+ 4
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
+ 3
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.
+ 3
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))
+ 2
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))
+ 1
import pandas as pd
filename = input()
column_name = input()
df = pd.read_csv(filename)
print(df[column_name].values)
+ 1
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)
+ 1
import pandas as pd
import numpy as np
filename = input()
column_name = input()
fl= pd.read_csv(filename)
print (fl[column_name].values)
+ 1
import numpy as np
n = int(input())
X = []
for i in range(n):
X.append([float(x) for x in input().split()])
y = [int(x) for x in input().split()]
datapoint = [float(x) for x in input().split()]
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(X,y)
datapoint = np.array(datapoint).reshape(1,-1)
print(model.predict(datapoint[[0]])[0])
+ 1
filename = input()
column_name = input()
import pandas as pd
df = pd.read_csv(filename)
print(df[column_name].values)
0
丹ⓨㄩک廾, thank you, it works!
0
import pandas as pd
df = pd.read_csv('https://sololearn.com/uploads/files/one.csv')
arr = df[['a', 'b']].values
print(arr[:,0])
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.
0
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
0
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😀
0
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))
0
filename = input()
column_name = input()
import pandas as pd
df = pd.read_csv(filename)
print(df[column_name].values)
0
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]