2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pandas のread_sas()でsas7bdatを読み込むときに文字化けする

Last updated at Posted at 2019-04-01

問題

pandasで日本語が含まれるsasのファイル形式を読みこむと日本語が文字化ける
例えば

import pandas as pd
hoge = pd.read_sas('hogehoge.sas7bdat')

ってやると日本語が文字化けする

import pandas as pd
hoge = pd.read_sas('hogehoge.sas7bdat', encdofing='cp932')

とかにしてみると今度はエラーが出る

こまった

解決

sas7bdatパッケージをインストールしてそれ経由で読みこむ

コード(らしきもの)

インストール

pip install sas7bdat

読み込み

from sas7bdat import SAS7BDAT
f=SAS7BDAT("hogehoge.sas7bdat", encoding='cp932').to_data_frame()

たぶんこれで動くようになるはず

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?