mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
55 lines
6.6 KiB
JSON
55 lines
6.6 KiB
JSON
{
|
||
"data": {
|
||
"question": {
|
||
"questionId": "3064",
|
||
"questionFrontendId": "2888",
|
||
"categoryTitle": "pandas",
|
||
"boundTopicId": 2453767,
|
||
"title": "Reshape Data: Concatenate",
|
||
"titleSlug": "reshape-data-concatenate",
|
||
"content": "<pre>\nDataFrame <code>df1</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\nDataFrame <code>df2</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\n</pre>\n\n<p>Write a solution to concatenate these two DataFrames <strong>vertically</strong> into one DataFrame.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\ndf1</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n+------------+---------+-----+\n<strong>df2\n</strong>+------------+------+-----+\n| student_id | name | age |\n+------------+------+-----+\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+------+-----+\n<strong>Output:</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+---------+-----+\n<strong>Explanation:\n</strong>The two DataFramess are stacked vertically, and their rows are combined.</pre>\n",
|
||
"translatedTitle": "重塑数据:连结",
|
||
"translatedContent": "<pre>\nDataFrame <code>df1</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\nDataFrame <code>df2</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\n</pre>\n\n<p>编写一个解决方案,将两个 DataFrames <b>垂直 </b>连接成一个 DataFrame。</p>\n\n<p>结果格式如下示例所示。</p>\n\n<p> </p>\n\n<p><strong class=\"example\">示例 1:</strong></p>\n\n<pre>\n<strong>输入:\ndf1</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n+------------+---------+-----+\n<strong>df2\n</strong>+------------+------+-----+\n| student_id | name | age |\n+------------+------+-----+\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+------+-----+\n<b>输出:</b>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+---------+-----+\n<strong>解释:\n</strong>两个 DataFrame 被垂直堆叠,它们的行被合并。</pre>\n",
|
||
"isPaidOnly": false,
|
||
"difficulty": "Easy",
|
||
"likes": 0,
|
||
"dislikes": 0,
|
||
"isLiked": null,
|
||
"similarQuestions": "[]",
|
||
"contributors": [],
|
||
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
|
||
"topicTags": [],
|
||
"companyTagStats": null,
|
||
"codeSnippets": [
|
||
{
|
||
"lang": "Pandas",
|
||
"langSlug": "pythondata",
|
||
"code": "import pandas as pd\n\ndef concatenateTables(df1: pd.DataFrame, df2: pd.DataFrame) -> pd.DataFrame:\n ",
|
||
"__typename": "CodeSnippetNode"
|
||
}
|
||
],
|
||
"stats": "{\"totalAccepted\": \"1.3K\", \"totalSubmission\": \"1.5K\", \"totalAcceptedRaw\": 1318, \"totalSubmissionRaw\": 1525, \"acRate\": \"86.4%\"}",
|
||
"hints": [
|
||
"Consider using a built-in function in pandas library with the appropriate axis argument."
|
||
],
|
||
"solution": null,
|
||
"status": null,
|
||
"sampleTestCase": "{\"headers\":{\"df1\":[\"student_id\",\"name\",\"age\"],\"df2\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"df1\":[[1,\"Mason\",8],[2,\"Ava\",6],[3,\"Taylor\",15],[4,\"Georgia\",17]],\"df2\":[[5,\"Leo\",7],[6,\"Alex\",7]]}}",
|
||
"metaData": "{\n \"pythondata\": [\n \"df1 = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\",\n \"df2 = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"concatenateTables\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
|
||
"judgerAvailable": true,
|
||
"judgeType": "large",
|
||
"mysqlSchemas": [],
|
||
"enableRunCode": true,
|
||
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
|
||
"book": null,
|
||
"isSubscribed": false,
|
||
"isDailyQuestion": false,
|
||
"dailyRecordStatus": null,
|
||
"editorType": "CKEDITOR",
|
||
"ugcQuestionId": null,
|
||
"style": "LEETCODE",
|
||
"exampleTestcases": "{\"headers\":{\"df1\":[\"student_id\",\"name\",\"age\"],\"df2\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"df1\":[[1,\"Mason\",8],[2,\"Ava\",6],[3,\"Taylor\",15],[4,\"Georgia\",17]],\"df2\":[[5,\"Leo\",7],[6,\"Alex\",7]]}}",
|
||
"__typename": "QuestionNode"
|
||
}
|
||
}
|
||
} |