首页 > 解决方案 > 运行 python 代码时出现 FutureWarning: elementwise comparison failed 错误

问题描述

我正在尝试在 python 脚本下运行。我收到错误。我尽力解决没有摆脱这个问题。

通常这种问题不会出现。我尝试使用警告模块。请指导我如何解决这个问题。

你能帮我么?

蟒蛇脚本:

import pandas as pd
import subprocess
import sys
import warnings
import os
import time
import datetime
import pwd
import logging
import uuid
import boto3
import pandas as pd
import csv
import pwd
import numpy as np
from boto3.s3.transfer import S3Transfer
from parameter_file_input import *
#warnings.simplefilter(action='ignore', category=FutureWarning)
file_to_df = '/home/hadoop/medaff/Metadata/Join_metadata.txt'
def join_condition(TableName):
    meta_df = pd.read_csv(file_to_df, delimiter='|')
    #meta_df.set_index(['0'], inplace=True)
    meta_df = meta_df[meta_df['TableName']==TableName]
    if meta_df.empty == True:
        return ''
    seq_max = int(meta_df['Sequnce'].max())
    query = ''
    print(query)
    for i in range(1, seq_max+1):
        counter = 0
        meta_df_temp = meta_df[meta_df['Sequnce'] == i]
        for index,row in meta_df_temp.iterrows():
            query+=' '
            print(query)
            if pd.isna(row['operator']):
                print("Operator Null")
                if counter==0:
                    if pd.isna(row['Aliastable']):
                        print("Aliastable Null")
                        query += row['jointype']+' '+row['Childtable']+' on ('+row['Parenttable']+'.'+row['columnname']+'='+row['Childtable']+'.'+row['child column']+' and '
                    else:
                        print("Aliastable not Null")
                        query += row['jointype']+' '+row['Aliastable']+' '+row['Childtable']+' on ('+row['Parenttable']+'.'+row['columnname']+'='+row['Childtable']+'.'+row['child column']+' and '
                else:
                    query += row['Parenttable']+'.'+row['columnname']+'='+row['Childtable']+'.'+row['child column']+' and '
            else:
                print("Operator not Null")
                if counter==0:
                    if pd.isna(row['Aliastable']):
                        print("Aliastable Null")
                        query += row['jointype']+' '+row['Childtable']+' on ('+row['Parenttable']+'.'+row['columnname']+' '+row['operator']+' '+row['Childtable']+'.'+row['child column']+' and '
                    else:
                        print("Aliastable not Null")
                        query += row['jointype']+' '+row['Aliastable']+' '+row['Childtable']+' on ('+row['Parenttable']+'.'+row['columnname']+' '+row['operator']+' '+row['Childtable']+'.'+row['child column']+' and '
                else:
                    query += row['Parenttable']+'.'+row['columnname']+' '+row['operator']+' '+row['Childtable']+'.'+row['child column']+' and '
            counter+=1
        counter = 0
        query = query[:0-len(' and ')]+')'
        query = query.lstrip(')')
    return query
print(join_condition('TERR'))

错误:

/home/hadoop/.local/lib/python2.7/site-packages/pandas/core/ops.py:1649: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  result = method(y)

标签: pythonpython-2.7

解决方案


推荐阅读