mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
59 lines
4.7 KiB
JSON
59 lines
4.7 KiB
JSON
{
|
|
"data": {
|
|
"question": {
|
|
"questionId": "3064",
|
|
"questionFrontendId": "2888",
|
|
"boundTopicId": null,
|
|
"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": null,
|
|
"translatedContent": null,
|
|
"isPaidOnly": false,
|
|
"difficulty": "Easy",
|
|
"likes": 26,
|
|
"dislikes": 4,
|
|
"isLiked": null,
|
|
"similarQuestions": "[]",
|
|
"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]]}}",
|
|
"categoryTitle": "pandas",
|
|
"contributors": [],
|
|
"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\": \"8.9K\", \"totalSubmission\": \"10.1K\", \"totalAcceptedRaw\": 8901, \"totalSubmissionRaw\": 10061, \"acRate\": \"88.5%\"}",
|
|
"hints": [
|
|
"Consider using a built-in function in pandas library with the appropriate axis argument."
|
|
],
|
|
"solution": {
|
|
"id": "2102",
|
|
"canSeeDetail": true,
|
|
"paidOnly": false,
|
|
"hasVideoSolution": false,
|
|
"paidOnlyVideo": true,
|
|
"__typename": "ArticleNode"
|
|
},
|
|
"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,
|
|
"enableTestMode": false,
|
|
"enableDebugger": false,
|
|
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
|
|
"libraryUrl": null,
|
|
"adminUrl": null,
|
|
"challengeQuestion": null,
|
|
"__typename": "QuestionNode"
|
|
}
|
|
}
|
|
} |