0Pricing
Data Science Academy · 课时

行、列与索引

建立 DataFrame 的思维模型

行、列与索引 是 CoddyKit 上的免费 Data Science Academy 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Data Science Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Data Science Academy 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

A Table You Can Code

A DataFrame is pandas' spreadsheet in code: rows and columns of data you can slice, sort, and compute on instantly. 📊

Two Axes, One Grid

Every DataFrame has two axes: rows run top to bottom, columns run left to right. Together they form one tidy grid of values.

Columns Are the Variables

Each column holds one variable, like price or city, and shares a single data type. Think of a column as one measured thing.

Rows Are the Records

Each row is one record: a customer, a day, a sale. Read a row across and you get the full story of one observation.

Meet the Index

The index is the label down the left side that names every row. By default it counts 0, 1, 2, but it can be anything unique.

df.index

Columns Have Labels Too

The column headers form their own label set, the columns attribute. You select data by these names instead of guessing positions.

df.columns

Shape Tells the Size

The shape attribute returns rows and columns as a pair. shape[0] is your row count, shape[1] is your column count.

df.shape  # (rows, cols)

One Column Is a Series

Pull a single column and pandas hands you a Series: a one-dimensional labeled array. A DataFrame is really a stack of Series.

df["price"]

Set a Meaningful Index

You can promote a column to be the index when it identifies rows, like an order id. It makes lookups clearer and faster.

df.set_index("order_id")

Labels Drive Everything

Pandas aligns and joins data by labels, not row order. That is why a thoughtful index quietly powers most of your analysis.

Reset When You Need To

Need a plain counting index back? reset_index moves the current index into a column and gives you fresh 0-based labels.

df.reset_index()

Quick Check

Time to test the mental model of a DataFrame.

Recap: The DataFrame Map

Rows are records, columns are variables, and the index labels every row. Know this map and the rest of pandas clicks. 🗺️

常见问题解答

「行、列与索引」课时是免费的吗?

是的 — 「行、列与索引」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Data Science Academy 课程的其余内容,请升级到 CoddyKit PRO。 Data Science Academy 课程共包含 4 节课。

「行、列与索引」这节课中我会学到什么?

建立 DataFrame 的思维模型 你通过在浏览器中直接运行的动手代码来练习 Data Science Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Data Science Academy 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Data Science Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。

「行、列与索引」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Data Science Academy 课中编写并运行代码吗?

能。每节 Data Science Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 行、列与索引
  2. 从头构建 DataFrame
  3. head、info 和 describe
  4. 添加、重命名和删除列
← 返回 Data Science Academy