3
2

More than 5 years have passed since last update.

はじめてのpandas

Last updated at Posted at 2019-03-29

pandasを使い始めたので、忘備録的に書いていく。

pandasって何?

csvとか一定の規則性を持って書かれたファイルを取り扱うのに便利なpythonライブラリ。
numpyだと扱えない文字列とかも取り扱える。
データの整理とかに便利らしいので使ってみることにした。

pandasをインポート

import pandas as pd

データを読み込む

  • 列がカンマで分けられているとき
hoge = pd.read_csv("hoge.csv")
  • タブキーで分けられているとき
hoge = pd.read_table("hoge.txt")
  • スペースや空白で分けられているとき
hoge = pd.read_csv("hoge.txt", delim_whitespace=True)
  • その他何らかの文字で分けられているとき
hoge = pd.read_csv("hoge.txt", sep="なにか区切り文字")

列を呼び出す

hoge[['任意の列タイトル1','任意の列タイトル2',]]
3
2
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
3
2