Skip to content

Commit e584658

Browse files
authored
🌐 [translation-sync] [pandas, pandas_panel] Update lectures for pandas 3.0 compatibility (#67)
* Update translation: lectures/pandas.md * Update translation: .translate/state/pandas.md.yml * Update translation: lectures/pandas_panel.md * Update translation: .translate/state/pandas_panel.md.yml
1 parent 8233c0e commit e584658

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

.translate/state/pandas.md.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
source-sha: 02e57a5befc2a9a081019edc748aba15e4b2f02a
2-
synced-at: "2026-04-09"
1+
source-sha: 811accdd4ed8803df3a7123ada3b560bc3110712
2+
synced-at: "2026-06-19"
33
model: claude-sonnet-4-6
44
mode: UPDATE
55
section-count: 5
6-
tool-version: 0.14.0
6+
tool-version: 0.15.0
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
source-sha: 126eb49056ad1b685638c1820ebb7b4c89cabf89
2-
synced-at: "2026-03-20"
1+
source-sha: 811accdd4ed8803df3a7123ada3b560bc3110712
2+
synced-at: "2026-06-19"
33
model: claude-sonnet-4-6
4-
mode: NEW
4+
mode: UPDATE
55
section-count: 6
6-
tool-version: 0.13.0
6+
tool-version: 0.15.0

lectures/pandas.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ df.loc[(df.cc + df.cg >= 80) & (df.POP <= 20000), ['country', 'year', 'POP']]
282282

283283
**应用:对数据框进行子集化**
284284

285-
现实世界的数据集可能[非常庞大](https://developers.google.com/machine-learning/crash-course/overfitting)
285+
现实世界的数据集可能 [非常庞大](https://developers.google.com/machine-learning/crash-course/overfitting)
286286

287287
有时需要使用数据的子集来提高计算效率并减少冗余。
288288

@@ -360,10 +360,10 @@ df.loc[complexCondition]
360360

361361
修改数据框的能力对于生成用于未来分析的干净数据集非常重要。
362362

363-
**1.** 我们可以方便地使用 `df.where()` 来"保留"我们已选择的行,并用任何其他值替换其余行
363+
**1.** 我们可以方便地使用 `df.where()` 来"保留"我们已选择的行,并将其余行替换为 `NaN`
364364

365365
```{code-cell} ipython3
366-
df.where(df.POP >= 20000, False)
366+
df.where(df.POP >= 20000)
367367
```
368368

369369
**2.** 我们可以简单地使用 `.loc[]` 来指定我们想要修改的列,并赋值:
@@ -433,7 +433,7 @@ df
433433

434434
缺失值插补是数据科学中的一个大领域,涉及各种机器学习技术。
435435

436-
Python 中还有更多[高级工具](https://scikit-learn.org/stable/modules/impute.html)可用于插补缺失值。
436+
Python 中还有更多 [高级工具](https://scikit-learn.org/stable/modules/impute.html) 可用于插补缺失值。
437437

438438
### 标准化与可视化
439439

lectures/pandas_panel.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,21 @@ realwage['United States'].head()
152152
`.stack()` 将列 `MultiIndex` 的最低层级旋转到行索引(`.unstack()` 方向相反——可以尝试一下)
153153

154154
```{code-cell} ipython3
155-
realwage.stack(future_stack=True).head()
155+
realwage.stack().head()
156156
```
157157

158158
我们也可以传入参数来选择要堆叠的层级
159159

160160
```{code-cell} ipython3
161-
realwage.stack(level='Country', future_stack=True).head() # pandas>3.0 之前需要 future_stack=True
161+
realwage.stack(level='Country').head()
162162
```
163163

164164
使用 `DatetimeIndex` 可以方便地选择特定时间段。
165165

166166
选择某一年并堆叠 `MultiIndex` 的两个较低层级,可以创建面板数据的横截面
167167

168168
```{code-cell} ipython3
169-
realwage.loc['2015'].stack(level=(1, 2), future_stack=True).transpose().head() # pandas>3.0 之前需要 future_stack=True
169+
realwage.loc['2015'].stack(level=(1, 2)).transpose().head()
170170
```
171171

172172
在本讲座的其余部分,我们将使用一个包含各国和各时间段每小时实际最低工资的数据框,以 2015 年美元计价。
@@ -363,7 +363,7 @@ plt.show()
363363

364364
我们还可以指定 `MultiIndex` 的某个层级(在列轴上)进行聚合。
365365

366-
对于 `groupby`,由于 pandas 已弃用在 `groupby` 方法中使用 `axis=1`,我们需要使用 `.T` 将列转置为行。
366+
对于 `groupby`,由于 `pandas` 已移除在 `groupby` 方法中使用 `axis=1` 的支持,我们需要使用 `.T` 将列转置为行。
367367

368368
```{code-cell} ipython3
369369
merged.T.groupby(level='Continent').mean().head()
@@ -393,7 +393,7 @@ plt.show()
393393
`.describe()` 可用于快速检索多个常用汇总统计量
394394

395395
```{code-cell} ipython3
396-
merged.stack(future_stack=True).describe()
396+
merged.stack().describe()
397397
```
398398

399399
这是使用 `groupby` 的一种简化方式。
@@ -563,4 +563,4 @@ plt.show()
563563
```
564564

565565
```{solution-end}
566-
```
566+
```

0 commit comments

Comments
 (0)