0Pricing
Data Science Academy · レッスン

1つまたは複数の列で並べ替える

昇順、降順、同順位

「1つまたは複数の列で並べ替える」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはData Science Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Data Science Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Order Brings Insight

Raw rows arrive in no useful order. Sorting puts the most interesting records on top so patterns jump out at a glance. 🔎

sort_values Is Your Tool

In pandas you reorder rows with sort_values. You name the column to sort by, and pandas hands back a freshly ordered DataFrame.

df.sort_values("price")

Ascending by Default

By default sort_values goes smallest to largest. So numbers climb upward and text sorts alphabetically from A to Z.

Flip to Descending

Set ascending=False when you want the biggest values first, like the top-selling products or the highest scores.

df.sort_values("sales", ascending=False)

Sort by Many Columns

Pass a list of columns and pandas sorts by the first, then breaks ties using the next, and so on down the list.

df.sort_values(["region", "sales"])

Mixed Sort Directions

Give ascending a list too, one flag per column. That lets you sort region A to Z while sales go high to low.

df.sort_values(["region", "sales"], ascending=[True, False])

A New Frame, Not In Place

By default sort_values returns a sorted copy and leaves the original untouched, so your source data stays safe.

Sort In Place If You Mean It

Add inplace=True to rewrite the original DataFrame instead of returning a copy. Use it only when you truly want that.

Watch the Index

Sorting keeps each row label glued to its data, so the index looks shuffled afterward. That is expected, not a bug.

Reset for Clean Numbers

Want tidy 0,1,2 labels after sorting? Chain reset_index with drop=True to renumber rows from the top.

df.sort_values("sales").reset_index(drop=True)

Where NaN Values Land

Missing values sink to the bottom by default. Set na_position to first if you would rather see them up top.

Quick Check

You want the highest sales on top. How do you sort?

Recap: Sorting Made Simple

You now sort with sort_values, flip with ascending, break ties using a column list, and tidy labels with reset_index. Nicely done! 🎉

よくある質問

「1つまたは複数の列で並べ替える」レッスンは無料ですか?

はい。「1つまたは複数の列で並べ替える」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。

「1つまたは複数の列で並べ替える」で何を学びますか?

昇順、降順、同順位 ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Data Science Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「1つまたは複数の列で並べ替える」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このData Science Academyレッスンでコードを書いて実行できますか?

はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 1つまたは複数の列で並べ替える
  2. 初めてのgroupby集計
  3. matplotlibで折れ線グラフと棒グラフ
  4. ラベル、タイトル、凡例
← Data Science Academyに戻る