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/method-chaining.json
2023-12-09 19:57:46 +08:00

53 lines
6.7 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"data": {
"question": {
"questionId": "3063",
"questionFrontendId": "2891",
"categoryTitle": "pandas",
"boundTopicId": 2467482,
"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&nbsp;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>&nbsp;</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&#39;s weight is 464, Jonathan&#39;s weight is 463, Tommy&#39;s weight is 349, and Alex&#39;s weight is 328.\nThe results should be sorted in descending order of weight.</pre>\n\n<p>&nbsp;</p>\n<p>In Pandas, <strong>method chaining</strong> enables us to&nbsp;perform operations on a DataFrame without breaking up each operation into a separate line or creating multiple temporary variables.&nbsp;</p>\n\n<p>Can you complete this&nbsp;task in just <strong>one line </strong>of code using method chaining?</p>\n",
"translatedTitle": "方法链",
"translatedContent": "<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>编写一个解决方案来列出体重 <strong>严格超过&nbsp;</strong>&nbsp;<code>100</code>&nbsp; 千克的动物的名称。</p>\n\n<p>按体重 <strong>降序</strong> 返回动物。</p>\n\n<p>返回结果格式如下示例所示。</p>\n\n<p>&nbsp;</p>\n\n<p><b>示例 1:</b></p>\n\n<pre>\n<b>输入:</b>\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<b>输出:</b>\n+----------+\n| name |\n+----------+\n| Tatiana |\n| Jonathan |\n| Tommy |\n| Alex |\n+----------+\n<b>解释:</b>\n所有体重超过 100 的动物都应包含在结果表中。\nTatiana 的体重为 464Jonathan 的体重为 463Tommy 的体重为 349Alex 的体重为 328。\n结果应按体重降序排序。</pre>\n\n<p>&nbsp;</p>\n\n<p>在 Pandas 中,<strong>方法链</strong> 允许我们在 DataFrame 上执行操作,而无需将每个操作拆分成单独的行或创建多个临时变量。</p>\n\n<p>你能用 <strong>一行</strong> 代码的方法链完成这个任务吗?</p>\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 findHeavyAnimals(animals: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"1.2K\", \"totalSubmission\": \"1.6K\", \"totalAcceptedRaw\": 1184, \"totalSubmissionRaw\": 1603, \"acRate\": \"73.9%\"}",
"hints": [],
"solution": null,
"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,
"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\":{\"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]]}}",
"__typename": "QuestionNode"
}
}
}