名前とインデックスを持つ列
Seriesがリストと異なる点を学びます
「名前とインデックスを持つ列」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはData Science Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Data Science Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Meet the Series
A Series is pandas' one-dimensional column: a sequence of values that all share one name and one type. Think of it as a single spreadsheet column. 📊
More Than a List
A plain Python list just holds values in order. A Series pairs every value with a label, so each item has both a position and a name you can look up by.
Create One Quickly
Pass any list to pd.Series and pandas wraps it for you. This line below builds your very first Series from three numbers.
import pandas as pd
s = pd.Series([10, 20, 30])
print(s)The Hidden Index
Notice the numbers on the left of your output. That is the index: a label for every value. Without one supplied, pandas auto-numbers from 0.
Give It Real Labels
You can set meaningful labels with the index argument. Now each value is named, which makes lookups read like plain English. 🏷️
s = pd.Series([90, 75, 88], index=['Ada', 'Bo', 'Cy'])
print(s['Bo'])One Type Inside
Every Series carries a single dtype, like int64 or float64. Shared types are what let pandas run fast math across the whole column at once.
print(s.dtype)Name the Whole Series
A Series can also carry its own name, separate from the index. That name becomes the column header once the Series joins a DataFrame.
s.name = 'score'
print(s.name)Values and Index Apart
You can pull the two parts out on their own. The .values attribute gives the raw data array; .index gives the labels that tag it.
print(s.values)
print(s.index)Build From a Dict
Hand pd.Series a dictionary and the keys become the index automatically. It is the fastest way to build a labeled column in one step.
ages = pd.Series({'Ada': 36, 'Bo': 41})
print(ages)Length and Peek
len(s) tells you how many values sit inside, and .head() shows just the first few. Both are handy first checks on any Series.
print(len(s))
print(s.head(2))The Column Building Block
Stack several Series side by side and you get a DataFrame. So mastering the Series means you already understand half of pandas. 🧱
Quick Check
Let's lock in what a Series carries.
Recap
You learned a Series is a named, single-typed column where every value has an index label. It is the basic block that DataFrames are built from. Nice work! 🎉
よくある質問
「名前とインデックスを持つ列」レッスンは無料ですか?
はい。「名前とインデックスを持つ列」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。
「名前とインデックスを持つ列」で何を学びますか?
Seriesがリストと異なる点を学びます ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Data Science Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「名前とインデックスを持つ列」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このData Science Academyレッスンでコードを書いて実行できますか?
はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 名前とインデックスを持つ列
- ラベルベースと位置ベースのアクセス
- Seriesの演算とアラインメント
- 値を数えて見つける