67
67

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 3 years have passed since last update.

pandasで特定の列を抽出する

Last updated at Posted at 2018-03-23

複数カラムあるcsvをデータフレームにインポートして、特定の列だけ抽出したいという
シチュエーションは皆さんよくあることだと思いますが、
私は書く度にググってるのので自分用のメモを書いときます。

csv ファイルに id, name ,desc という3つの項目が存在し、name と desc を抽出したいときは以下の様に書きます。


import pandas as pd

df = pd.read_csv("./test.csv")
df = df[["name","desc"]]

リストをネストするのがポイントです。

67
67
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
67
67

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?