Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c30fe4c

Browse files
Added the problem description
1 parent f501f19 commit c30fe4c

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

‎30-days-pandas/0595-big-countries.py‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
1+
"""
2+
595. Big Countries
3+
Solved
4+
Easy
5+
Topics
6+
Companies
7+
SQL Schema
8+
Pandas Schema
9+
Table: World
10+
11+
+-------------+---------+
12+
| Column Name | Type |
13+
+-------------+---------+
14+
| name | varchar |
15+
| continent | varchar |
16+
| area | int |
17+
| population | int |
18+
| gdp | bigint |
19+
+-------------+---------+
20+
name is the primary key (column with unique values) for this table.
21+
Each row of this table gives information about the name of a country, the continent to which it belongs, its area, the population, and its GDP value.
22+
23+
A country is big if:
24+
25+
it has an area of at least three million (i.e., 3000000 km2), or
26+
it has a population of at least twenty-five million (i.e., 25000000).
27+
Write a solution to find the name, population, and area of the big countries.
28+
29+
Return the result table in any order.
30+
31+
The result format is in the following example.
32+
33+
Example 1:
34+
35+
Input:
36+
World table:
37+
+-------------+-----------+---------+------------+--------------+
38+
| name | continent | area | population | gdp |
39+
+-------------+-----------+---------+------------+--------------+
40+
| Afghanistan | Asia | 652230 | 25500100 | 20343000000 |
41+
| Albania | Europe | 28748 | 2831741 | 12960000000 |
42+
| Algeria | Africa | 2381741 | 37100000 | 188681000000 |
43+
| Andorra | Europe | 468 | 78115 | 3712000000 |
44+
| Angola | Africa | 1246700 | 20609294 | 100990000000 |
45+
+-------------+-----------+---------+------------+--------------+
46+
Output:
47+
+-------------+------------+---------+
48+
| name | population | area |
49+
+-------------+------------+---------+
50+
| Afghanistan | 25500100 | 652230 |
51+
| Algeria | 37100000 | 2381741 |
52+
+-------------+------------+---------+
53+
"""
54+
155
import pandas as pd
256

357
def big_countries(world: pd.DataFrame) -> pd.DataFrame:

‎introduction-pandas/2879-display-first-rows.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
"""
2+
2879. Display the First Three Rows
3+
Solved
4+
Easy
5+
Companies
6+
Hint
7+
DataFrame: employees
8+
+-------------+--------+
9+
| Column Name | Type |
10+
+-------------+--------+
11+
| employee_id | int |
12+
| name | object |
13+
| department | object |
14+
| salary | int |
15+
+-------------+--------+
16+
Write a solution to display the first 3 rows of this DataFrame.
17+
18+
Example 1:
19+
20+
Input:
21+
DataFrame employees
22+
+-------------+-----------+-----------------------+--------+
23+
| employee_id | name | department | salary |
24+
+-------------+-----------+-----------------------+--------+
25+
| 3 | Bob | Operations | 48675 |
26+
| 90 | Alice | Sales | 11096 |
27+
| 9 | Tatiana | Engineering | 33805 |
28+
| 60 | Annabelle | InformationTechnology | 37678 |
29+
| 49 | Jonathan | HumanResources | 23793 |
30+
| 43 | Khaled | Administration | 40454 |
31+
+-------------+-----------+-----------------------+--------+
32+
Output:
33+
+-------------+---------+-------------+--------+
34+
| employee_id | name | department | salary |
35+
+-------------+---------+-------------+--------+
36+
| 3 | Bob | Operations | 48675 |
37+
| 90 | Alice | Sales | 11096 |
38+
| 9 | Tatiana | Engineering | 33805 |
39+
+-------------+---------+-------------+--------+
40+
Explanation:
41+
Only the first 3 rows are displayed.
42+
"""
43+
144
import pandas as pd
245

346
def selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /