更新於 2024/01/10閱讀時間約 6 分鐘

Method Chaining 函式呼叫鍊_Intro to Pandas


題目敘述

題目會給定一個pandas DataFrame作為輸入,要求我們列出所有體重>100公斤的動物的名字,並且必須依照體重weight降序排列


題目的原文敘述


測試範例

Example 1:

Input: 
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 |
+----------+---------+-----+--------+
Output:
+----------+
| name |
+----------+
| Tatiana |
| Jonathan |
| Tommy |
| Alex |
+----------+
Explanation:
All animals weighing more than 100 should be included in the results table.
Tatiana's weight is 464, Jonathan's weight is 463, Tommy's weight is 349, and Alex's weight is 328.
The results should be sorted in descending order of weight.

約束條件

分享至
成為作者繼續創作的動力吧!
© 2024 vocus All rights reserved.