1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/方法链 [method-chaining].html
2023-12-09 18:53:53 +08:00

55 lines
1.5 KiB
HTML
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.

<pre>
DataFrame <code>animals</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| name | object |
| species | object |
| age | int |
| weight | int |
+-------------+--------+
</pre>
<p>编写一个解决方案来列出体重 <strong>严格超过&nbsp;</strong>&nbsp;<code>100</code>&nbsp; 千克的动物的名称。</p>
<p>按体重 <strong>降序</strong> 返回动物。</p>
<p>返回结果格式如下示例所示。</p>
<p>&nbsp;</p>
<p><b>示例 1:</b></p>
<pre>
<b>输入:</b>
DataFrame animals:
+----------+---------+-----+--------+
| name | species | age | weight |
+----------+---------+-----+--------+
| Tatiana | Snake | 98 | 464 |
| Khaled | Giraffe | 50 | 41 |
| Alex | Leopard | 6 | 328 |
| Jonathan | Monkey | 45 | 463 |
| Stefan | Bear | 100 | 50 |
| Tommy | Panda | 26 | 349 |
+----------+---------+-----+--------+
<b>输出:</b>
+----------+
| name |
+----------+
| Tatiana |
| Jonathan |
| Tommy |
| Alex |
+----------+
<b>解释:</b>
所有体重超过 100 的动物都应包含在结果表中。
Tatiana 的体重为 464Jonathan 的体重为 463Tommy 的体重为 349Alex 的体重为 328。
结果应按体重降序排序。</pre>
<p>&nbsp;</p>
<p>在 Pandas 中,<strong>方法链</strong> 允许我们在 DataFrame 上执行操作,而无需将每个操作拆分成单独的行或创建多个临时变量。</p>
<p>你能用 <strong>一行</strong> 代码的方法链完成这个任务吗?</p>