Unify two or more variaves with jupyter notebook

Asked

Viewed 96 times

0

Good afternoon!

I have a database with the variables: number card, date of hospitalization and date of discharge. I want to unify the three variables in a single with the name Chave_hospitalization.

If it’s SAS, it’ll look like this: Chave_hospitalization = compress(card || data_hospitalization || high date);

However I am not able to do the same in jupyter notebook with python, how can I do it in python?

  • What type of data are variables? Are they strings? Or are they columns of data in a dataframe Pandas? Or are in a relational database ("database") - if yes, it is necessary to see the code of how you access this data to be able to answer the question.

1 answer

0


If you just want to concatenate the data, just use the operator +.

carteirinha = '12345'
data_internacao = '20190425'
data_alta = '20190426'

var = carteirinha+data_internacao+data_alta
var

Remembering that all fields should be as string, if they are not, it is possible to convert them using str().

About the SAS compress function, I never used it, but I imagine it has a similar function to the method Translate python

  • The various ones are in type Object, even so I can’t concatenate.

  • what happens when you try, makes mistake?

Browser other questions tagged

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