mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
57 lines
4.7 KiB
JSON
57 lines
4.7 KiB
JSON
{
|
|
"data": {
|
|
"question": {
|
|
"questionId": "3063",
|
|
"questionFrontendId": "2891",
|
|
"boundTopicId": null,
|
|
"title": "Method Chaining",
|
|
"titleSlug": "method-chaining",
|
|
"content": "<pre>\nDataFrame <code>animals</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| species | object |\n| age | int |\n| weight | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to list the names of animals that weigh <strong>strictly more than</strong> <code>100</code> kilograms.</p>\n\n<p>Return the animals sorted by weight in <strong>descending order</strong>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong>Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nDataFrame animals:\n+----------+---------+-----+--------+\n| name | species | age | weight |\n+----------+---------+-----+--------+\n| Tatiana | Snake | 98 | 464 |\n| Khaled | Giraffe | 50 | 41 |\n| Alex | Leopard | 6 | 328 |\n| Jonathan | Monkey | 45 | 463 |\n| Stefan | Bear | 100 | 50 |\n| Tommy | Panda | 26 | 349 |\n+----------+---------+-----+--------+\n<strong>Output:</strong> \n+----------+\n| name |\n+----------+\n| Tatiana |\n| Jonathan |\n| Tommy |\n| Alex |\n+----------+\n<strong>Explanation:</strong> \nAll animals weighing more than 100 should be included in the results table.\nTatiana's weight is 464, Jonathan's weight is 463, Tommy's weight is 349, and Alex's weight is 328.\nThe results should be sorted in descending order of weight.</pre>\n\n<p> </p>\n<p>In Pandas, <strong>method chaining</strong> enables us to perform operations on a DataFrame without breaking up each operation into a separate line or creating multiple temporary variables. </p>\n\n<p>Can you complete this task in just <strong>one line </strong>of code using method chaining?</p>\n",
|
|
"translatedTitle": null,
|
|
"translatedContent": null,
|
|
"isPaidOnly": false,
|
|
"difficulty": "Easy",
|
|
"likes": 22,
|
|
"dislikes": 4,
|
|
"isLiked": null,
|
|
"similarQuestions": "[]",
|
|
"exampleTestcases": "{\"headers\":{\"animals\":[\"name\",\"species\",\"age\",\"weight\"]},\"rows\":{\"animals\":[[\"Tatiana\",\"Snake\",98,464],[\"Khaled\",\"Giraffe\",50,41],[\"Alex\",\"Leopard\",6,328],[\"Jonathan\",\"Monkey\",45,463],[\"Stefan\",\"Bear\",100,50],[\"Tommy\",\"Panda\",26,349]]}}",
|
|
"categoryTitle": "pandas",
|
|
"contributors": [],
|
|
"topicTags": [],
|
|
"companyTagStats": null,
|
|
"codeSnippets": [
|
|
{
|
|
"lang": "Pandas",
|
|
"langSlug": "pythondata",
|
|
"code": "import pandas as pd\n\ndef findHeavyAnimals(animals: pd.DataFrame) -> pd.DataFrame:\n ",
|
|
"__typename": "CodeSnippetNode"
|
|
}
|
|
],
|
|
"stats": "{\"totalAccepted\": \"7.7K\", \"totalSubmission\": \"10.8K\", \"totalAcceptedRaw\": 7741, \"totalSubmissionRaw\": 10753, \"acRate\": \"72.0%\"}",
|
|
"hints": [],
|
|
"solution": {
|
|
"id": "2100",
|
|
"canSeeDetail": true,
|
|
"paidOnly": false,
|
|
"hasVideoSolution": false,
|
|
"paidOnlyVideo": true,
|
|
"__typename": "ArticleNode"
|
|
},
|
|
"status": null,
|
|
"sampleTestCase": "{\"headers\":{\"animals\":[\"name\",\"species\",\"age\",\"weight\"]},\"rows\":{\"animals\":[[\"Tatiana\",\"Snake\",98,464],[\"Khaled\",\"Giraffe\",50,41],[\"Alex\",\"Leopard\",6,328],[\"Jonathan\",\"Monkey\",45,463],[\"Stefan\",\"Bear\",100,50],[\"Tommy\",\"Panda\",26,349]]}}",
|
|
"metaData": "{\n \"pythondata\": [\n \"animals = pd.DataFrame([], columns=['name', 'species', 'age', 'weight']).astype({'name':'object', 'species':'object', 'age':'Int64', 'weight':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"findHeavyAnimals\",\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"
|
|
}
|
|
}
|
|
} |