how to correct error in sitanxis with column name in dataframe?

-1

I am executing this code to delete some records of a dataframe, but in line 16 (move_id / id) it is the name of the column and / separates the name of the column which is not ideal. the error response is "move_id" does not exist and it is true xq the column is called "move_id / id"

# -*- coding: utf-8 -*-
import matplotlib
matplotlib.use("Agg")
import numpy as np
import dataiku
from dataiku import pandasutils as pdu
import pandas as pd

# Read recipe inputs
mpicon_acc_move_line = dataiku.Dataset("MPICON_acc-move-line_")
mpicon_acc_move_line_df = mpicon_acc_move_line.get_dataframe()


#CODE
exclude = ['mig2018.account_move__b00004629','mig2018.account_move__b00004636','mig2018.account_move__b00004670']
df = mpicon_acc_move_line_df[~np.in1d(mpicon_acc_move_line_df.move_id/id, exclude)] 


# Write recipe outputs
mpicon_acc_move_line_filtered = dataiku.Dataset("MPICON_acc-move-line_filtered")
mpicon_acc_move_line_filtered.write_with_schema(df)
    
asked by Yan Chirino 21.09.2018 в 19:08
source

1 answer

1

The problem is that when writing:

mpicon_acc_move_line_df.move_id/id

Python interprets that you are trying to divide the values of the column move_id between the variable id , neither the column nor the variable have been previously declared.

To access the column you want, you should instead write:

mpicon_acc_move_line_df['move_id/id']
    
answered by 22.09.2018 / 08:02
source