2024-01-09|閱讀時間 ‧ 約 0 分鐘

Get the Size of a DataFrame 取得DataFrame的大小(資料表的寬度與高度)

題目敘述

題目會給定一個pandas DataFrame,要求我們回傳該紀錄表的高度和寬度,也就是對應的number of rows和number of columns。

題目的原文敘述


測試範例

Example 1:

Input:
+-----------+----------+-----+-------------+--------------------+
| player_id | name | age | position | team |
+-----------+----------+-----+-------------+--------------------+
| 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 |
+-----------+----------+-----+-------------+--------------------+
Output:
[10, 5]
Explanation:
This DataFrame contains 10 rows and 5 columns.

總共有10筆資料,每筆資料的欄位寬度為5

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