2024-01-09|閱讀時間 ‧ 約 0 分鐘

Reshape Data: Concatenate 串接兩張資料表_Intro to Pandas

題目敘述

題目會給定兩個pandas DataFrame作為輸入,要求我們將兩張資料表,依照原有的順序串接在一起。


題目的原文敘述


測試範例

Example 1:

Input:
df1
+------------+---------+-----+
| student_id | name | age |
+------------+---------+-----+
| 1 | Mason | 8 |
| 2 | Ava | 6 |
| 3 | Taylor | 15 |
| 4 | Georgia | 17 |
+------------+---------+-----+
df2
+------------+------+-----+
| student_id | name | age |
+------------+------+-----+
| 5 | Leo | 7 |
| 6 | Alex | 7 |
+------------+------+-----+
Output:
+------------+---------+-----+
| student_id | name | age |
+------------+---------+-----+
| 1 | Mason | 8 |
| 2 | Ava | 6 |
| 3 | Taylor | 15 |
| 4 | Georgia | 17 |
| 5 | Leo | 7 |
| 6 | Alex | 7 |
+------------+---------+-----+
Explanation:
The two DataFramess are stacked vertically, and their rows are combined.

兩張資料表依照原有順序,沿著垂直方向,串接在一起。​
分享至
成為作者繼續創作的動力吧!
© 2024 vocus All rights reserved.