This is probably a very stupid question but I have been searching for example on this site as well as others and I have yet to find an answer that works. I am trying to multiply two arrays and assign the values to a 2D array within nested loops.

正规365体育投注I have two variable 'cars' and 'scrappage'. I would like to multiply each element wise and create a 2D array that is 10x10.

I was able to do this in MATLAB but I am new to python, so I know I am probably using the Pandas dataframe incorrectly. I have tried to debug the code, and everything runs exactly as it should (creation of data frames, loops, etc.) with the exception of the array multiplication and values being assigned to the 2D array.

I know this is an indexing error I keep receiving the "IndexError: single positional indexer is out-of-bounds" message.

Here is my code:

```
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
cars = pd.DataFrame([1000,2000,3000,4000,5000,6000,7000,8000,9000,10000])
scrappage = pd.DataFrame([1,.95,.86,.75,.62,.44,.30,.20,.12,.04])
Fleet = pd.DataFrame([])
i=0
j=0
for i in range(0,len(cars)):
for j in range(0,len(scrappage)):
Fleet.iloc[i,j]= cars.iloc[i,0] * scrappage.iloc[j,0]
#This^ line is causing the error.
j= j+1
i=i+1
```

I'm sure this is probably very simple for most but I am struggling with the Pandas syntax. Thank you in advance for any help.

`cars[0].values[:, None] * scrappage[0].values`

to get your 2D array and then put it back to a DF – Jon Clements♦ May 23 at 23:34`np.outer(cars, scrappage)`

) – Jon Clements♦ May 23 at 23:35