Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions