mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
59 lines
4.6 KiB
JSON
59 lines
4.6 KiB
JSON
{
|
|
"data": {
|
|
"question": {
|
|
"questionId": "3068",
|
|
"questionFrontendId": "2885",
|
|
"boundTopicId": null,
|
|
"title": "Rename Columns",
|
|
"titleSlug": "rename-columns",
|
|
"content": "<pre>\nDataFrame <code>students</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| id | int |\n| first | object |\n| last | object |\n| age | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to rename the columns as follows:</p>\n\n<ul>\n\t<li><code>id</code> to <code>student_id</code></li>\n\t<li><code>first</code> to <code>first_name</code></li>\n\t<li><code>last</code> to <code>last_name</code></li>\n\t<li><code>age</code> to <code>age_in_years</code></li>\n</ul>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:\n</strong>+----+---------+----------+-----+\n| id | first | last | age |\n+----+---------+----------+-----+\n| 1 | Mason | King | 6 |\n| 2 | Ava | Wright | 7 |\n| 3 | Taylor | Hall | 16 |\n| 4 | Georgia | Thompson | 18 |\n| 5 | Thomas | Moore | 10 |\n+----+---------+----------+-----+\n<strong>Output:</strong>\n+------------+------------+-----------+--------------+\n| student_id | first_name | last_name | age_in_years |\n+------------+------------+-----------+--------------+\n| 1 | Mason | King | 6 |\n| 2 | Ava | Wright | 7 |\n| 3 | Taylor | Hall | 16 |\n| 4 | Georgia | Thompson | 18 |\n| 5 | Thomas | Moore | 10 |\n+------------+------------+-----------+--------------+\n<strong>Explanation:</strong> \nThe column names are changed accordingly.</pre>\n",
|
|
"translatedTitle": null,
|
|
"translatedContent": null,
|
|
"isPaidOnly": false,
|
|
"difficulty": "Easy",
|
|
"likes": 20,
|
|
"dislikes": 1,
|
|
"isLiked": null,
|
|
"similarQuestions": "[]",
|
|
"exampleTestcases": "{\"headers\":{\"students\":[\"id\",\"first\",\"last\",\"age\"]},\"rows\":{\"employees\":[],\"students\":[[1,\"Mason\",\"King\",6],[2,\"Ava\",\"Wright\",7],[3,\"Taylor\",\"Hall\",16],[4,\"Georgia\",\"Thompson\",18],[5,\"Thomas\",\"Moore\",10]]}}",
|
|
"categoryTitle": "pandas",
|
|
"contributors": [],
|
|
"topicTags": [],
|
|
"companyTagStats": null,
|
|
"codeSnippets": [
|
|
{
|
|
"lang": "Pandas",
|
|
"langSlug": "pythondata",
|
|
"code": "import pandas as pd\n\ndef renameColumns(students: pd.DataFrame) -> pd.DataFrame:\n ",
|
|
"__typename": "CodeSnippetNode"
|
|
}
|
|
],
|
|
"stats": "{\"totalAccepted\": \"9.5K\", \"totalSubmission\": \"11.3K\", \"totalAcceptedRaw\": 9476, \"totalSubmissionRaw\": 11307, \"acRate\": \"83.8%\"}",
|
|
"hints": [
|
|
"Consider using a build-in function in pandas library with a dictionary to rename the columns as specified."
|
|
],
|
|
"solution": {
|
|
"id": "2104",
|
|
"canSeeDetail": true,
|
|
"paidOnly": false,
|
|
"hasVideoSolution": false,
|
|
"paidOnlyVideo": true,
|
|
"__typename": "ArticleNode"
|
|
},
|
|
"status": null,
|
|
"sampleTestCase": "{\"headers\":{\"students\":[\"id\",\"first\",\"last\",\"age\"]},\"rows\":{\"employees\":[],\"students\":[[1,\"Mason\",\"King\",6],[2,\"Ava\",\"Wright\",7],[3,\"Taylor\",\"Hall\",16],[4,\"Georgia\",\"Thompson\",18],[5,\"Thomas\",\"Moore\",10]]}}",
|
|
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['id', 'first', 'last', 'age']).astype({'id':'Int64', 'first':'object', 'last':'object', 'age':'Int64'})\\n\"\n ],\n \"database\": true,\n \"name\": \"renameColumns\",\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"
|
|
}
|
|
}
|
|
} |