0Pricing
Data Science Academy · レッスン

きれいなフィルターにqueryとisinを使う

多くの値を読みやすく絞り込む

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

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

Toward Cleaner Filters

Long chains of ampersands get hard to read. Two tools, query and isin, make complex filtering far more pleasant. ✨

Filter With a String

The query method lets you describe the filter as plain text, so you skip the repeated df name and bracket noise.

df.query("age > 30")

query Uses Plain and or

Inside query you write natural words like and and or, instead of the symbols you needed in bracket filtering.

df.query("age > 30 and city == 'Paris'")

Reference Python Variables

Pull an outside value into a query string by prefixing it with an at sign. This keeps thresholds out of the literal text.

limit = 30
df.query("age > @limit")

Comparing Two Columns

A big win of query is comparing columns to each other directly, naming both inside the same readable string.

df.query("score > target")

Many Values With isin

To match any value from a list, isin beats chaining many OR conditions. It returns a clean boolean mask.

df[df["city"].isin(["Paris", "Lyon", "Nice"])]

Invert isin to Exclude

Combine the tilde with isin to keep rows that are not in your list, a tidy way to exclude several values at once.

df[~df["city"].isin(["Paris", "Lyon"])]

isin Inside query

You can even call isin from within a query string, blending the two tools for readable multi-value filters.

df.query("city in ['Paris', 'Lyon']")

isin Checks Values, Not Columns

Remember that isin tests each cell against a fixed list of allowed values. It is not meant for comparing one column to another column.

df[df["status"].isin(["open", "pending"])]

query Returns a New DataFrame

Like bracket filtering, query leaves the original untouched and hands back a fresh DataFrame to assign or chain.

result = df.query("age > 30")

Choosing Your Style

Reach for query when logic is long and English-like, and for isin when one column must match many values. Pick whatever reads clearest.

Quick Check

Choose the cleanest tool for the job.

Recap: query and isin

Use query for readable English-like filters with @variables, and isin to match many values at once. Your filters stay clean and clear. ✅

よくある質問

「きれいなフィルターにqueryとisinを使う」レッスンは無料ですか?

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

「きれいなフィルターにqueryとisinを使う」で何を学びますか?

多くの値を読みやすく絞り込む ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「きれいなフィルターにqueryとisinを使う」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. 名前で列を選ぶ
  2. 条件で行を絞り込む
  3. ANDとORでフィルターを組み合わせる
  4. きれいなフィルターにqueryとisinを使う
← Data Science Academyに戻る