0

Before reading into pandas my data looks like in sas dataset

Name 
Alfred
Alice

After reading into pandas data is getting as

Name 
b'Alfred'
b'Alice'

Why I am getting the data is different? Steps followed:

  1. Import pandas as pd
  2. df=pd.read_sas(r'C:/ProgramData/Anaconda3/Python_local/class.sas7bdat',format='sas7bdat')

Need your help.

E. Sommer
  • 710
  • 1
  • 7
  • 28
  • Please check this https://stackoverflow.com/questions/40389764/how-to-translate-bytes-objects-into-literal-strings-in-pandas-dataframe-pytho – BarathVutukuri Jan 14 '20 at 06:31
  • 1
    It is actually the same. SAS stores bytes you get bytes. It is only how python present bytes – Lee Jan 14 '20 at 12:22

1 Answers1

0

SAS files need to be imported with special encoding

df=pd.read_sas(r'C:/ProgramData/Anaconda3/Python_local/class.sas7bdat',format='sas7bdat', encoding='iso-8859-1') 
E. Sommer
  • 710
  • 1
  • 7
  • 28