简体   繁体   中英

How to divide two columns of type `pandas.core.series.Series`?

I need to divide two series element wise. The elements are of type float.

A = [10,20,30]
B = [2,5,5]
result = A/B

I expect

result = [5,4,6]

but get

result = [NaN, NaN, NaN]

This just works with pandas Series as expected:

In [3]: import pandas as pd

In [4]: A = pd.Series([10,20,30])

In [5]: B = pd.Series([2,5,5])

In [6]: A/B
Out[6]:
0    5
1    4
2    6
dtype: float64

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM