EasyNo. 2878

Get the Size of a DataFrame — LeetCode 2878 Python Solution

Topics
Pandas
Reading time
2 min

Table schema

SQLTable schema
DataFrame players: +-------------+--------+ | Column Name | Type | +-------------+--------+ | player_id | int | | name | object | | age | int | | position | object | | ... | ...

Example

SQLExample
DataFrame players:
+-------------+--------+
| Column Name | Type   |
+-------------+--------+
| player_id   | int    |
| name        | object |
| age         | int    |
| position    | object |
| ...         | ...    |
+-------------+--------+

Python solution

PythonSolution
import pandas as pd


def getDataframeSize(players: pd.DataFrame) -> List[int]:
    return list(players.shape)

Complexity

Time
O(n)
Space · auxiliary
O(1) to O(n)

Related problems

Frequently asked questions

How hard is LeetCode 2878. Get the Size of a DataFrame?

LeetCode 2878. Get the Size of a DataFrame is rated Easy on LeetCode.

What topics does LeetCode 2878. Get the Size of a DataFrame cover?

LeetCode 2878. Get the Size of a DataFrame is tagged Pandas on LeetCode.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity, invisible to screen sharing.

Free to download. Check it runs on your machine, then pick a plan.