Relate two Dataframes in pandas and return value in python

Asked

Viewed 278 times

0

I have two Dataframes, both in csv that import in pandas, one with the history of protocol records and one with a list of people authorized to make changes in the records of procotolos.

How can I make a new dataframe where I check that the person who made the change to the protocol record is on the list of authorized people? Also return an unauthorized 'Authorized' value'?

I’m using the jupyter notebook

The only columns in common is the login column, but they have different names. The login column in the history table is the CUSUAR_INCL_REG column.

History data.

inserir a descrição da imagem aqui

Access data.

inserir a descrição da imagem aqui

Therefore, I wanted to return a new column in the history table with the return: 'You are in the access list' or 'you are not in the access list'.

  • 1

    Could you please put a snippet of the data sets so that we can better understand the problem?

  • Hi @joão, I entered the question. Thank you very much.

1 answer

0

Expensive,

I was in doubt with your placement below.

The only columns in common is the login column, but they have different names. The login column in the history table is the CUSUAR_INCL_REG column.

But in the tables you presented, even the data are different.

Imagining that there is equal data in the said columns, you can use the merge

novo_dataframe = pd.merge(dfhistorico, dfacesso, left_on=['CUSUAR_INCL_REG'], right_on=['LOGIN'])

Take a look at documentation, for the merge has several parameters.

I hope it helps

Browser other questions tagged

You are not signed in. Login or sign up in order to post.