mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
update
This commit is contained in:
59
leetcode/problem/reshape-data-concatenate.html
Normal file
59
leetcode/problem/reshape-data-concatenate.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<pre>
|
||||
DataFrame <code>df1</code>
|
||||
+-------------+--------+
|
||||
| Column Name | Type |
|
||||
+-------------+--------+
|
||||
| student_id | int |
|
||||
| name | object |
|
||||
| age | int |
|
||||
+-------------+--------+
|
||||
|
||||
DataFrame <code>df2</code>
|
||||
+-------------+--------+
|
||||
| Column Name | Type |
|
||||
+-------------+--------+
|
||||
| student_id | int |
|
||||
| name | object |
|
||||
| age | int |
|
||||
+-------------+--------+
|
||||
|
||||
</pre>
|
||||
|
||||
<p>Write a solution to concatenate these two DataFrames <strong>vertically</strong> into one DataFrame.</p>
|
||||
|
||||
<p>The result format is in the following example.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:
|
||||
df1</strong>
|
||||
+------------+---------+-----+
|
||||
| student_id | name | age |
|
||||
+------------+---------+-----+
|
||||
| 1 | Mason | 8 |
|
||||
| 2 | Ava | 6 |
|
||||
| 3 | Taylor | 15 |
|
||||
| 4 | Georgia | 17 |
|
||||
+------------+---------+-----+
|
||||
<strong>df2
|
||||
</strong>+------------+------+-----+
|
||||
| student_id | name | age |
|
||||
+------------+------+-----+
|
||||
| 5 | Leo | 7 |
|
||||
| 6 | Alex | 7 |
|
||||
+------------+------+-----+
|
||||
<strong>Output:</strong>
|
||||
+------------+---------+-----+
|
||||
| student_id | name | age |
|
||||
+------------+---------+-----+
|
||||
| 1 | Mason | 8 |
|
||||
| 2 | Ava | 6 |
|
||||
| 3 | Taylor | 15 |
|
||||
| 4 | Georgia | 17 |
|
||||
| 5 | Leo | 7 |
|
||||
| 6 | Alex | 7 |
|
||||
+------------+---------+-----+
|
||||
<strong>Explanation:
|
||||
</strong>The two DataFramess are stacked vertically, and their rows are combined.</pre>
|
Reference in New Issue
Block a user