1
0

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で#行を無視して読み込む

Posted at

TL;DR

csvファイルとかだとまず行内に#から入るコメントアウト行が入ってたりすることはないと思いますが、バイオインフォマティクス特有のgffやらvcfやらbedやらはコメント行が含まれていて、普通にpandasで読み込むのがめんどくさかったので調べました。pandasは賢いのでそういう機能もあるようです。

comment引数

解決策は非常に簡単で、読み込む時にcomment引数にコメントの最初につける記号を入れるだけです。

import pandas as pd


df = pd.read_csv("/path/to/file", comment='#')

これで読み込めないイライラが解消される...

1
0
0

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?