Using pandas dataframe function .mul in Python 3.x -


i'm trying multiply 2 dataframes mul() function, it's not working.

i created 2 dataframes:

x = np.arange(0.,5.,0.2) m = len(x) ones  = np.ones(m) theta = {'1':np.zeros(2)} x = {'1':pd.series(ones), '2':pd.series(x)} thetadf = pd.dataframe(theta) xdf = pd.dataframe(x) 

and tried this:

mult = xdf.mul(thetadf) print (mult) 

the result is:

        1   2 0   0.0 nan 1   0.0 nan 2   nan nan 3   nan nan 4   nan nan 5   nan nan 6   nan nan 7   nan nan 8   nan nan 9   nan nan 10  nan nan 11  nan nan 12  nan nan 13  nan nan 14  nan nan 15  nan nan 16  nan nan 17  nan nan 18  nan nan 19  nan nan 20  nan nan 21  nan nan 22  nan nan 23  nan nan 24  nan nan 

should use way multiply?

head line solution

thetadf.index = xdf.columns  mult = xdf.dot(thetadf) 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -