The problem is how do you load rows from a pandas dataframe to a numpy array for line by line processing? While there are many questions on a similar issue, this issue is unique in that it requires line-by-line processing, which I have facilitated with a for loop. The for loop intends to take each row in the dataframe as a numpy array and multiply it by another numpy array with arbitrary floating point values. The minimum function is defined below.
def function():
#Load Data
data = pd.read_csv('data.csv')
#Forward
for row in data:
variable_matrix = np.array([[header_0, header_1], [header_2, header_3]])
weight_matrix = np.array([[0.01, 0.01], [0.01, 0.01]])
output = np.matmul(variable_matrix, weight_matrix)
print(output)
The output error that is returning is as follows.
variable_matrix = np.array([[header_0, header_1], [header_2, header_3]])
NameError: name 'header_0' is not defined
Intuitively, the array would take in the value associated with header_0
in the first row in this instance. However, the machine is unable to recognize this value, despite the fact that it is defined in the header of the pandas dataframe, which has been loaded as a datafile from data.csv
.
Any thoughts or suggestions would be greatly appreciated. Thank you.