python - FutureWarning: elementwise comparison failed; returning scalar, but in the future will perform elementwise comparison result = getattr(x, name)(y) -


i using pandas 0.19.1 on python 3. getting warning on these lines of code. trying list contains row numbers word peter present @ column unnamed: 5.

df = pd.read_excel(xls_path) myrows = df[df['unnamed: 5'] == 'peter'].index.tolist() 

warning:

"\python36\lib\site-packages\pandas\core\ops.py:792: futurewarning: elementwise comparison failed; returning scalar, in future perform elementwise comparison  result = getattr(x, name)(y)" 

any ideas?

my experience same warning message caused typeerror.

typeerror: invalid type comparison

so, may want check data type of unnamed: 5

for x in df['unnamed: 5']:   print(type(x))  # 'str' ? 

here how can replicate warning message:

import pandas pd import numpy np df = pd.dataframe(np.random.randn(3, 2), columns=['num1', 'num2']) df['num3'] = 3 df.loc[df['num3'] == '3', 'num3'] = 4  # typeerror , warning df.loc[df['num3'] == 3, 'num3'] = 4  # no error 

hope helps.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -