1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/originData/display-the-first-three-rows.json
2023-12-09 19:57:46 +08:00

55 lines
6.6 KiB
JSON

{
"data": {
"question": {
"questionId": "3065",
"questionFrontendId": "2879",
"categoryTitle": "pandas",
"boundTopicId": 2467489,
"title": "Display the First Three Rows",
"titleSlug": "display-the-first-three-rows",
"content": "<pre>\nDataFrame: <code>employees</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| employee_id | int |\n| name | object |\n| department | object |\n| salary | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to display the <strong>first <code>3</code> </strong>rows<strong> </strong>of this DataFrame.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>DataFrame employees\n+-------------+-----------+-----------------------+--------+\n| employee_id | name | department | salary |\n+-------------+-----------+-----------------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n| 60 | Annabelle | InformationTechnology | 37678 |\n| 49 | Jonathan | HumanResources | 23793 |\n| 43 | Khaled | Administration | 40454 |\n+-------------+-----------+-----------------------+--------+\n<strong>Output:</strong>\n+-------------+---------+-------------+--------+\n| employee_id | name | department | salary |\n+-------------+---------+-------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n+-------------+---------+-------------+--------+\n<strong>Explanation:</strong> \nOnly the first 3 rows are displayed.</pre>\n",
"translatedTitle": "显示前三行",
"translatedContent": "<pre>\nDataFrame: <code>employees</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| employee_id | int |\n| name | object |\n| department | object |\n| salary | int |\n+-------------+--------+\n</pre>\n\n<p>编写一个解决方案,显示这个 DataFrame 的<strong> 前&nbsp;&nbsp;<code>3</code>&nbsp;</strong>行。</p>\n\n<p>&nbsp;</p>\n\n<p><b>示例 1:</b></p>\n\n<pre>\n<strong>输入:\n</strong>DataFrame employees\n+-------------+-----------+-----------------------+--------+\n| employee_id | name | department | salary |\n+-------------+-----------+-----------------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n| 60 | Annabelle | InformationTechnology | 37678 |\n| 49 | Jonathan | HumanResources | 23793 |\n| 43 | Khaled | Administration | 40454 |\n+-------------+-----------+-----------------------+--------+\n<b>输出:</b>\n+-------------+---------+-------------+--------+\n| employee_id | name | department | salary |\n+-------------+---------+-------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n+-------------+---------+-------------+--------+\n<b>解释:</b>\n只有前 3 行被显示。</pre>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 1,
"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 selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"2.1K\", \"totalSubmission\": \"2.3K\", \"totalAcceptedRaw\": 2136, \"totalSubmissionRaw\": 2313, \"acRate\": \"92.3%\"}",
"hints": [
"Consider using a built-in function in pandas library to retrieve the initial rows."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"employees\":[\"employee_id\",\"name\",\"department\",\"salary\"]},\"rows\":{\"employees\":[[3,\"Bob\",\"Operations\",48675],[90,\"Alice\",\"Sales\",11096],[9,\"Tatiana\",\"Engineering\",33805],[60,\"Annabelle\",\"InformationTechnology\",37678],[49,\"Jonathan\",\"HumanResources\",23793],[43,\"Khaled\",\"Administration\",40454]]}}",
"metaData": "{\n \"pythondata\": [\n \"employees = pd.DataFrame([], columns=['employee_id', 'name', 'department', 'salary']).astype({'employee_id':'Int64', 'name':'object', 'department':'object', 'salary':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"selectFirstRows\",\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\":{\"employees\":[\"employee_id\",\"name\",\"department\",\"salary\"]},\"rows\":{\"employees\":[[3,\"Bob\",\"Operations\",48675],[90,\"Alice\",\"Sales\",11096],[9,\"Tatiana\",\"Engineering\",33805],[60,\"Annabelle\",\"InformationTechnology\",37678],[49,\"Jonathan\",\"HumanResources\",23793],[43,\"Khaled\",\"Administration\",40454]]}}",
"__typename": "QuestionNode"
}
}
}