• Skip to main content
  • Skip to primary sidebar

学習記録

Pandas

scatter_matrix

2018年1月28日 by 河副 太智 Leave a Comment

スキャッターマトリクスと色づけ

1
2
grr = pd.scatter_matrix(iris_dataframe,c=y_train,figsize=(15,15),marker="o",
                       hist_kwds={"bins":20},s=60,alpha=.8,cmap=mglearn.cm3)

 

Filed Under: Pandas

データフレームでスライスが使えない

2018年1月16日 by 河副 太智 Leave a Comment

TypeError: unhashable type: ‘slice’

とエラーが出てデータフレームでスライスが使えない場合は以下のように
ilocを使う

1
2
3
4
5
6
7
8
train = pd.read_csv('train.csv', header = 0, dtype={'Age': np.float64})
test  = pd.read_csv('test.csv' , header = 0, dtype={'Age': np.float64})
full_data = [train, test]
 
 
dataset = pd.DataFrame(np.random.rand(10, 10))#random無くてもいける
y=train.iloc[0::, 1::]
X=train.iloc[0::, 0]

 

Filed Under: Pandas

データセットの数、カラム、型の一覧表示

2018年1月16日 by 河副 太智 Leave a Comment

1
train.info()

RangeIndex: 891 entries, 0 to 890
Data columns (total 12 columns):
PassengerId 891 non-null int64
Survived 891 non-null int64
Pclass 891 non-null int64
Name 891 non-null object
Sex 891 non-null object
Age 714 non-null float64
SibSp 891 non-null int64
Parch 891 non-null int64
Ticket 891 non-null object
Fare 891 non-null float64
Cabin 204 non-null object
Embarked 889 non-null object
dtypes: float64(2), int64(5), object(5)
memory usage: 83.6+ KB
None

Filed Under: Pandas

データの選択、特定

2018年1月16日 by 河副 太智 Leave a Comment

選択、特定

1
2
3
4
5
6
df[col] # Returns column with label col as Series
df[[col1, col2]] # Returns Columns as a new DataFrame
s.iloc[0] # Selection by position (selects first element)
s.loc[0] # Selection by index (selects element at index 0)
df.iloc[0,:] # First row
df.iloc[0,0] # First element of first column

 

Filed Under: Pandas

データセットの最初の5行だけ出す

2017年12月31日 by 河副 太智 Leave a Comment

1
2
3
4
5
6
import numpy as np
import pandas as pd
 
iris_dataset = load_iris()
 
print(iris_dataset["data"][:5])

1
2
3
4
5
[[ 5.1  3.5  1.4  0.2]
[ 4.9  3.   1.4  0.2]
[ 4.7  3.2  1.3  0.2]
[ 4.6  3.1  1.5  0.2]
[ 5.   3.6  1.4  0.2]]

Filed Under: Pandas

データフレームを綺麗に表示

2017年12月31日 by 河副 太智 Leave a Comment

1
2
3
4
5
6
7
8
9
import pandas as pd
from IPython.display import display
 
data ={"name":["jonh","anna","peter","linda"],
      "location":["new york","paris","berlin","london"],
      "age":[24,13,53,33]}
 
data_pandas = pd.DataFrame(data)
display(data_pandas)

 

 

Filed Under: Pandas

  • « Go to Previous Page
  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Interim pages omitted …
  • Page 8
  • Go to Next Page »

Primary Sidebar

カテゴリー

  • AWS
  • Bootstrap
  • Dash
  • Django
  • flask
  • GIT(sourcetree)
  • Plotly/Dash
  • VPS
  • その他tool
  • ブログ
  • プログラミング
    • Bokeh
    • css
    • HoloViews
    • Jupyter
    • Numpy
    • Pandas
    • PosgreSQL
    • Python 基本
    • python3
      • webアプリ
    • python3解説
    • scikit-learn
    • scipy
    • vps
    • Wordpress
    • グラフ
    • コマンド
    • スクレイピング
    • チートシート
    • データクレンジング
    • ブロックチェーン
    • 作成実績
    • 時系列分析
    • 機械学習
      • 分析手法
      • 教師有り
    • 異常値検知
    • 自然言語処理
  • 一太郎
  • 数学
    • sympy
      • 対数関数(log)
      • 累乗根(n乗根)
    • 暗号学

Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in