Question: For my Python lab I have to load data with pandas, convert a pandas dataframe to a numpy array and then get the first column

 For my Python lab I have to load data with pandas,

For my Python lab I have to load data with pandas, convert a pandas dataframe to a numpy array and then get the first column and the second to last column from numpy array as vectors. Everything was working fine, but I also have to find the inner product of product of the vectors and I keep getting this error. How do I fix it?

In [2]; import numpy as np import pandas as pd # load data with pandas df = pd.read_csv('/Users/maguireqvale/cars.cvs') #convert a pandas dataframe to a numpy array X = df.values[:, 1:-1] #Get the first column and the second to last column from X as vectors c1 X[:,:1] c2 = X[:,1:] # 3. inner product np.inner (ci, c2) ValueError Traceback (most recent call last) in 13 14 # 3. inner product 15 np.inner(c1, c2) ---> array_function internals> in inner(*args, **kwargs) ValueError: shapes (406,1) and (6,406) not aligned: 1 (dim 1) != 6 (dim 0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!