0

I got res = dataframe * dataframe['column'] with <class 'pandas.core.frame.DataFrame'> for the first dataframe and <class 'pandas.core.series.Series'> for dataframe['column']

And it outputs me : res : 2020-08-17 05:00:00 2020-08-17 05:15:00 2020-08-17 05:30:00 ... dtime 2020-08-24 16:45:00 NaN NaN NaN ... 2020-08-24 16:30:00 NaN NaN NaN ... 2020-08-24 16:15:00 NaN NaN NaN ... 2020-08-24 16:00:00 NaN NaN NaN ... 2020-08-24 15:45:00 NaN NaN NaN ... ... 2020-08-17 06:00:00 NaN NaN NaN ... 2020-08-17 05:45:00 NaN NaN NaN ... 2020-08-17 05:30:00 NaN NaN NaN ... 2020-08-17 05:15:00 NaN NaN NaN ... 2020-08-17 05:00:00 NaN NaN NaN ...

Everything that I find tells me that "*" is suppose to give me : res : dtime 2020-08-24 16:45:00 floatValue 2020-08-24 16:30:00 floatValue 2020-08-24 16:15:00 floatValue 2020-08-24 16:00:00 floatValue 2020-08-24 15:45:00 floatValue ... 2020-08-17 06:00:00 floatValue 2020-08-17 05:45:00 floatValue 2020-08-17 05:30:00 floatValue 2020-08-17 05:15:00 floatValue 2020-08-17 05:00:00 floatValue

I'm sure I'm missing something, but I can't find what.

Edit :

import pandas
df = pandas.DataFrame({"angles": [0, 3, 4], "degrees": [360, 180, 360]}, index=["circle", "triangle", "rectangle"])
other = pandas.DataFrame({"angles": [0, 3, 4]}, index=["circle", "triangle", "rectangle"])
print("df * other :", df * other)

is giving me :

df * other :
           angles  degrees
circle          0      NaN
triangle        9      NaN
rectangle      16      NaN

as expected. So maybe it has to do with the datetimeIndex.

Edit :

import pandas

df = pandas.DataFrame({'angles': [0, 3, 4], 'degrees': [360, 180, 360]}, index=['2020-08-17 05:30:00', '2020-08-17 05:15:00', '2020-08-17 05:00:00'])
other = pandas.DataFrame({'angles': [0, 3, 4]}, index=['2020-08-17 05:30:00', '2020-08-17 05:15:00', '2020-08-17 05:00:00'])
df.index = pandas.to_datetime(df.index, format='%Y-%m-%d %H:%M:%S')
other.index = pandas.to_datetime(other.index, format='%Y-%m-%d %H:%M:%S')

print("df * other :", df * other)

is giving :

df * other :         angles  degrees
2020-08-17 05:30:00       0      NaN
2020-08-17 05:15:00       9      NaN
2020-08-17 05:00:00      16      NaN

So it's not the datetimeIndex.

TheHaricover
  • 47
  • 1
  • 6

1 Answers1

0

in your small example, you are multiplying df * df[i.e. other ]. you will get the same problem if you use df *df.angles [i.e. df * series ]

but in the main problem, you are using df * series. try using df * pd.DataFrame(df.col) .

in df * series: it compares column wise same as df.multiply(df.series,axis=1) you can try df.multiply(df.series,axis=0) as well

Ave799
  • 187
  • 7