• Skip to main content
  • Skip to primary sidebar

学習記録

DataFrame sort()

2017年11月25日 by 河副 太智 Leave a Comment

1
 

1
2
3
<span role="presentation"><span class="cm-comment"><code>変数.sort_values(by="カラムリスト", ascending=True)</code>とするとの列の値について
</span></span>小さい順にソートされたDataFrameを生成リストの順番が早い列が優先的にソート
ascending=False</code>とすると、大きい順にソート

1
2
3
<span role="presentation"><span class="cm-comment">
 
# dfを"apple", "orange", "banana", "strawberry", "kiwifruit"の優先度の順に昇順にソート</span></span>

1
<span role="presentation"><span class="cm-variable">df</span> = <span class="cm-variable">df</span>.<span class="cm-property">sort_values</span><span class=" CodeMirror-matchingbracket">(</span><span class="cm-variable">columns</span><span class=" CodeMirror-matchingbracket">)</span></span>

1
<span role="presentation">​</span>

1
<span role="presentation"><span class="cm-builtin">print</span>(<span class="cm-variable">df</span>)</span>
1
2
3
4
5
6
7
8
9
10
11
    apple  orange  banana  strawberry  kiwifruit
2       1       7      10           4         10
9       3       9       6           1          3
7       4       8       1           4          3
3       4       9       9           9          1
4       4       9      10           2          5
10      5       2       1           2          1
8       6       8       4           8          8
1       6       8       6           3         10
5       8       2       5           4          8
6      10       7       4           4          4
このエントリーをはてなブックマークに追加

Tweet
[`yahoo` not found]
このエントリーを Google ブックマーク に追加
LinkedIn にシェア
LINEで送る


Filed Under: Numpy, Pandas

Reader Interactions

コメントを残す コメントをキャンセル

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です

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