0Pricing
Data Science Academy · レッスン

値を数えて見つける

value_counts、unique、簡単な確認方法を学びます

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

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

Get to Know Your Column

Before any analysis, you want a feel for what is inside a Series. A few quick methods summarize the contents in seconds. 🔍

A Sample Series

Here is a Series of fruit names with some repeats. We will explore its contents with handy built-in methods.

import pandas as pd
s = pd.Series(['apple', 'pear', 'apple', 'fig', 'pear', 'apple'])

Count Each Value

The value_counts method tallies how often each value appears, sorted from most to least common. It is the fastest frequency check.

print(s.value_counts())

See the Distinct Set

Call unique to get every distinct value just once, in the order first seen. It answers what kinds of values you have.

print(s.unique())

How Many Distinct

The nunique method returns the count of distinct values as a single number. Here it tells you how many fruit kinds exist.

print(s.nunique())

Shares Instead of Counts

Add normalize=True to value_counts and you get proportions instead of raw counts. Now each fruit's share sums to one.

print(s.value_counts(normalize=True))

Spot Missing Values

The isna method flags each value that is missing as True. Summing those flags counts the gaps in your column at a glance.

nums = pd.Series([1.0, None, 3.0])
print(nums.isna().sum())

Check Membership

Use isin with a list to test which values belong to a chosen set. It returns a boolean mask you can filter with later.

print(s.isin(['apple', 'fig']))

Find the Extremes

For numbers, max and min surface the largest and smallest values instantly, without sorting the whole Series yourself.

print(nums.max(), nums.min())

One-Shot Overview

The describe method bundles count, unique, top, and frequency for text, giving a tidy snapshot in a single call. 📋

print(s.describe())

Your Inspection Toolkit

Together these methods are your first inspection pass on any column. A minute spent here saves hours of confused analysis later. 🧰

Quick Check

Pick the right tool for a frequency tally.

Recap

You can now profile a Series with value_counts, unique, nunique, isna, and isin. These quick checks reveal what your data holds. Well done! 🎉

よくある質問

「値を数えて見つける」レッスンは無料ですか?

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

「値を数えて見つける」で何を学びますか?

value_counts、unique、簡単な確認方法を学びます ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「値を数えて見つける」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. 名前とインデックスを持つ列
  2. ラベルベースと位置ベースのアクセス
  3. Seriesの演算とアラインメント
  4. 値を数えて見つける
← Data Science Academyに戻る