0Pricing
Data Science Academy · レッスン

ゼロからDataFrameを作成する

辞書、リスト、配列から

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

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

Why Build Your Own

Before loading real files, building a small DataFrame by hand lets you test ideas and learn the structure with zero setup. 🧪

Import pandas First

Every project starts the same way: import pandas under the nickname pd. That short alias is a universal convention you will see everywhere.

import pandas as pd

From a Dictionary of Columns

The most common recipe is a dict where each key is a column name and each value is a list of that column's data.

df = pd.DataFrame({"name": ["Ada", "Lin"], "age": [36, 41]})

Keys Become Headers

With the dict approach, the dictionary keys turn into your column headers automatically. Naming columns is as easy as naming keys.

From a List of Rows

You can also pass a list of rows and supply the column names separately. Handy when your data already arrives row by row.

pd.DataFrame([["Ada", 36], ["Lin", 41]], columns=["name", "age"])

From a List of Dicts

A list of dicts works too, with one dict per row. Missing keys simply become blanks, which is great for uneven records.

pd.DataFrame([{"name": "Ada"}, {"name": "Lin", "age": 41}])

From a NumPy Array

Have a NumPy array of numbers? Pass it straight in and add column names. This bridges fast NumPy math with labeled tables.

pd.DataFrame(arr, columns=["x", "y"])

Set the Index on Creation

Pass an index argument to label your rows the moment you build the frame, instead of relying on default 0, 1, 2 numbers.

pd.DataFrame(data, index=["r1", "r2"])

Control the Column Order

Want columns in a specific order? Pass a columns list and pandas arranges them exactly as you list, ignoring dict ordering quirks.

pd.DataFrame(data, columns=["age", "name"])

Lengths Must Match

Every column you provide must have the same length. Mismatched list sizes raise an error, so keep your columns even.

Peek at What You Built

After building, glance at dtypes to confirm pandas inferred sensible types like int for ages and object for names.

df.dtypes

Quick Check

Pick the building block behind the most common DataFrame recipe.

Recap: Many Ways In

Dicts, lists, list-of-dicts, or NumPy arrays all become a DataFrame. Pick whatever matches the shape of your data. 🛠️

よくある質問

「ゼロからDataFrameを作成する」レッスンは無料ですか?

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

「ゼロからDataFrameを作成する」で何を学びますか?

辞書、リスト、配列から ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「ゼロからDataFrameを作成する」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. 行、列、インデックス
  2. ゼロからDataFrameを作成する
  3. head、info、describe
  4. 列の追加、名前変更、削除
← Data Science Academyに戻る