0

I am trying to extract data from a dummy csv file to use inside tensorflow. The dummy data only has 2 columns: X (single feature column) and Y (expected output).

X     Y 
11.0 13.0
23.0 33.3 
...  ...  and so on

Right now I am reading the data like so:

import pandas as pd

dummy_data = pd.read_csv("dummy_data.csv", sep=",")
inputX = dummy_data.loc[:, 'X'].values
np.reshape(inputX, [11, 1])

I am reshaping the numpy array because I need to do matrix multiplication later on with linear regression but I want to ask is that the correct way to extract a column from csv data? Is there a better way to directly extract the csv data to a tensor object?

1 Answer 1

1

There is no need to reshape or use .loc or .values:

inputX = dummy_data[['X']]

(Mind the list of lists [[]]!)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.