mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
59 lines
5.4 KiB
JSON
59 lines
5.4 KiB
JSON
{
|
|
"data": {
|
|
"question": {
|
|
"questionId": "3076",
|
|
"questionFrontendId": "2878",
|
|
"boundTopicId": null,
|
|
"title": "Get the Size of a DataFrame",
|
|
"titleSlug": "get-the-size-of-a-dataframe",
|
|
"content": "<pre>\nDataFrame <code>players:</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| player_id | int |\n| name | object |\n| age | int |\n| position | object |\n| ... | ... |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to calculate and display the <strong>number of rows and columns</strong> of <code>players</code>.</p>\n\n<p>Return the result as an array:</p>\n\n<p><code>[number of rows, number of columns]</code></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:\n</strong>+-----------+----------+-----+-------------+--------------------+\n| player_id | name | age | position | team |\n+-----------+----------+-----+-------------+--------------------+\n| 846 | Mason | 21 | Forward | RealMadrid |\n| 749 | Riley | 30 | Winger | Barcelona |\n| 155 | Bob | 28 | Striker | ManchesterUnited |\n| 583 | Isabella | 32 | Goalkeeper | Liverpool |\n| 388 | Zachary | 24 | Midfielder | BayernMunich |\n| 883 | Ava | 23 | Defender | Chelsea |\n| 355 | Violet | 18 | Striker | Juventus |\n| 247 | Thomas | 27 | Striker | ParisSaint-Germain |\n| 761 | Jack | 33 | Midfielder | ManchesterCity |\n| 642 | Charlie | 36 | Center-back | Arsenal |\n+-----------+----------+-----+-------------+--------------------+<strong>\nOutput:\n</strong>[10, 5]\n<strong>Explanation:</strong>\nThis DataFrame contains 10 rows and 5 columns.\n</pre>\n",
|
|
"translatedTitle": null,
|
|
"translatedContent": null,
|
|
"isPaidOnly": false,
|
|
"difficulty": "Easy",
|
|
"likes": 42,
|
|
"dislikes": 6,
|
|
"isLiked": null,
|
|
"similarQuestions": "[]",
|
|
"exampleTestcases": "{\"headers\":{\"players\":[\"player_id\",\"name\",\"age\",\"position\",\"team\"]},\"rows\":{\"players\":[[846,\"Mason\",21,\"Forward\",\"RealMadrid\"],[749,\"Riley\",30,\"Winger\",\"Barcelona\"],[155,\"Bob\",28,\"Striker\",\"ManchesterUnited\"],[583,\"Isabella\",32,\"Goalkeeper\",\"Liverpool\"],[388,\"Zachary\",24,\"Midfielder\",\"BayernMunich\"],[883,\"Ava\",23,\"Defender\",\"Chelsea\"],[355,\"Violet\",18,\"Striker\",\"Juventus\"],[247,\"Thomas\",27,\"Striker\",\"ParisSaint-Germain\"],[761,\"Jack\",33,\"Midfielder\",\"ManchesterCity\"],[642,\"Charlie\",36,\"Center-back\",\"Arsenal\"]]}}",
|
|
"categoryTitle": "pandas",
|
|
"contributors": [],
|
|
"topicTags": [],
|
|
"companyTagStats": null,
|
|
"codeSnippets": [
|
|
{
|
|
"lang": "Pandas",
|
|
"langSlug": "pythondata",
|
|
"code": "import pandas as pd\n\ndef getDataframeSize(players: pd.DataFrame) -> List[int]:\n ",
|
|
"__typename": "CodeSnippetNode"
|
|
}
|
|
],
|
|
"stats": "{\"totalAccepted\": \"15.3K\", \"totalSubmission\": \"18.3K\", \"totalAcceptedRaw\": 15311, \"totalSubmissionRaw\": 18324, \"acRate\": \"83.6%\"}",
|
|
"hints": [
|
|
"Consider using a built-in function in pandas library to get the size of a DataFrame."
|
|
],
|
|
"solution": {
|
|
"id": "2109",
|
|
"canSeeDetail": true,
|
|
"paidOnly": false,
|
|
"hasVideoSolution": false,
|
|
"paidOnlyVideo": true,
|
|
"__typename": "ArticleNode"
|
|
},
|
|
"status": null,
|
|
"sampleTestCase": "{\"headers\":{\"players\":[\"player_id\",\"name\",\"age\",\"position\",\"team\"]},\"rows\":{\"players\":[[846,\"Mason\",21,\"Forward\",\"RealMadrid\"],[749,\"Riley\",30,\"Winger\",\"Barcelona\"],[155,\"Bob\",28,\"Striker\",\"ManchesterUnited\"],[583,\"Isabella\",32,\"Goalkeeper\",\"Liverpool\"],[388,\"Zachary\",24,\"Midfielder\",\"BayernMunich\"],[883,\"Ava\",23,\"Defender\",\"Chelsea\"],[355,\"Violet\",18,\"Striker\",\"Juventus\"],[247,\"Thomas\",27,\"Striker\",\"ParisSaint-Germain\"],[761,\"Jack\",33,\"Midfielder\",\"ManchesterCity\"],[642,\"Charlie\",36,\"Center-back\",\"Arsenal\"]]}}",
|
|
"metaData": "{\n \"pythondata\": [\n \"players = pd.DataFrame([], columns=['player_id', 'name', 'age', 'position', 'team']).astype({'player_id':'Int64', 'name':'object', 'age':'Int64', 'position':'object', 'team':'object'})\"\n ],\n \"database\": true,\n \"name\": \"get_size\",\n \"languages\": [\n \"pythondata\"\n ],\n \"manual\": true\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"
|
|
}
|
|
}
|
|
} |