Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add new lc problems #1749

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions solution/2800-2899/2877.Create a DataFrame from List/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# [2877. Create a DataFrame from List](https://leetcode.cn/problems/create-a-dataframe-from-list)

[English Version](/solution/2800-2899/2877.Create%20a%20DataFrame%20from%20List/README_EN.md)

## 题目描述

<!-- 这里写题目描述 -->

<p>Write a solution to <strong>create</strong> a DataFrame from a 2D list called <code>student_data</code>. This 2D list contains the IDs and ages of some students.</p>

<p>The DataFrame should have two columns, <code>student_id</code> and <code>age</code>, and be in the same order as the original 2D list.</p>

<p>The result format is in the following example.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:
</strong>student_data:<strong>
</strong><code>[
[1, 15],
[2, 11],
[3, 11],
[4, 20]
]</code>
<strong>Output:</strong>
+------------+-----+
| student_id | age |
+------------+-----+
| 1 | 15 |
| 2 | 11 |
| 3 | 11 |
| 4 | 20 |
+------------+-----+
<strong>Explanation:</strong>
A DataFrame was created on top of student_data, with two columns named <code>student_id</code> and <code>age</code>.
</pre>

## 解法

<!-- 这里可写通用的实现逻辑 -->

<!-- tabs:start -->

### **Pandas**

<!-- 这里可写当前语言的特殊实现逻辑 -->

```python

```

### **...**

```

```

<!-- tabs:end -->
54 changes: 54 additions & 0 deletions solution/2800-2899/2877.Create a DataFrame from List/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# [2877. Create a DataFrame from List](https://leetcode.com/problems/create-a-dataframe-from-list)

[中文文档](/solution/2800-2899/2877.Create%20a%20DataFrame%20from%20List/README.md)

## Description

<p>Write a solution to <strong>create</strong> a DataFrame from a 2D list called <code>student_data</code>. This 2D list contains the IDs and ages of some students.</p>

<p>The DataFrame should have two columns, <code>student_id</code> and <code>age</code>, and be in the same order as the original 2D list.</p>

<p>The result format is in the following example.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:
</strong>student_data:<strong>
</strong><code>[
[1, 15],
[2, 11],
[3, 11],
[4, 20]
]</code>
<strong>Output:</strong>
+------------+-----+
| student_id | age |
+------------+-----+
| 1 | 15 |
| 2 | 11 |
| 3 | 11 |
| 4 | 20 |
+------------+-----+
<strong>Explanation:</strong>
A DataFrame was created on top of student_data, with two columns named <code>student_id</code> and <code>age</code>.
</pre>

## Solutions

<!-- tabs:start -->

### **Pandas**

```python

```

### **...**

```

```

<!-- tabs:end -->
75 changes: 75 additions & 0 deletions solution/2800-2899/2878.Get the Size of a DataFrame/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# [2878. Get the Size of a DataFrame](https://leetcode.cn/problems/get-the-size-of-a-dataframe)

[English Version](/solution/2800-2899/2878.Get%20the%20Size%20of%20a%20DataFrame/README_EN.md)

## 题目描述

<!-- 这里写题目描述 -->

<pre>
DataFrame <code>players:</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| player_id | int |
| name | object |
| age | int |
| position | object |
| ... | ... |
+-------------+--------+
</pre>

<p>Write a solution to calculate and display the <strong>number of rows and columns</strong> of <code>players</code>.</p>

<p>Return the result as an array:</p>

<p><code>[number of rows, number of columns]</code></p>

<p>The result format is in the following example.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:
</strong>+-----------+----------+-----+-------------+--------------------+
| 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 |
+-----------+----------+-----+-------------+--------------------+<strong>
Output:
</strong>[10, 5]
<strong>Explanation:</strong>
This DataFrame contains 10 rows and 5 columns.
</pre>

## 解法

<!-- 这里可写通用的实现逻辑 -->

<!-- tabs:start -->

### **Pandas**

<!-- 这里可写当前语言的特殊实现逻辑 -->

```python

```

### **...**

```

```

<!-- tabs:end -->
69 changes: 69 additions & 0 deletions solution/2800-2899/2878.Get the Size of a DataFrame/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# [2878. Get the Size of a DataFrame](https://leetcode.com/problems/get-the-size-of-a-dataframe)

[中文文档](/solution/2800-2899/2878.Get%20the%20Size%20of%20a%20DataFrame/README.md)

## Description

<pre>
DataFrame <code>players:</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| player_id | int |
| name | object |
| age | int |
| position | object |
| ... | ... |
+-------------+--------+
</pre>

<p>Write a solution to calculate and display the <strong>number of rows and columns</strong> of <code>players</code>.</p>

<p>Return the result as an array:</p>

<p><code>[number of rows, number of columns]</code></p>

<p>The result format is in the following example.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:
</strong>+-----------+----------+-----+-------------+--------------------+
| 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 |
+-----------+----------+-----+-------------+--------------------+<strong>
Output:
</strong>[10, 5]
<strong>Explanation:</strong>
This DataFrame contains 10 rows and 5 columns.
</pre>

## Solutions

<!-- tabs:start -->

### **Pandas**

```python

```

### **...**

```

```

<!-- tabs:end -->
70 changes: 70 additions & 0 deletions solution/2800-2899/2879.Display the First Three Rows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# [2879. Display the First Three Rows](https://leetcode.cn/problems/display-the-first-three-rows)

[English Version](/solution/2800-2899/2879.Display%20the%20First%20Three%20Rows/README_EN.md)

## 题目描述

<!-- 这里写题目描述 -->

<pre>
DataFrame: <code>employees</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| employee_id | int |
| name | object |
| department | object |
| salary | int |
+-------------+--------+
</pre>

<p>Write a solution to display the <strong>first <code>3</code> </strong>rows<strong> </strong>of this DataFrame.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:
</strong>DataFrame employees
+-------------+-----------+-----------------------+--------+
| employee_id | name | department | salary |
+-------------+-----------+-----------------------+--------+
| 3 | Bob | Operations | 48675 |
| 90 | Alice | Sales | 11096 |
| 9 | Tatiana | Engineering | 33805 |
| 60 | Annabelle | InformationTechnology | 37678 |
| 49 | Jonathan | HumanResources | 23793 |
| 43 | Khaled | Administration | 40454 |
+-------------+-----------+-----------------------+--------+
<strong>Output:</strong>
+-------------+---------+-------------+--------+
| employee_id | name | department | salary |
+-------------+---------+-------------+--------+
| 3 | Bob | Operations | 48675 |
| 90 | Alice | Sales | 11096 |
| 9 | Tatiana | Engineering | 33805 |
+-------------+---------+-------------+--------+
<strong>Explanation:</strong>
Only the first 3 rows are displayed.</pre>

## 解法

<!-- 这里可写通用的实现逻辑 -->

<!-- tabs:start -->

### **Pandas**

<!-- 这里可写当前语言的特殊实现逻辑 -->

```python

```

### **...**

```

```

<!-- tabs:end -->
64 changes: 64 additions & 0 deletions solution/2800-2899/2879.Display the First Three Rows/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# [2879. Display the First Three Rows](https://leetcode.com/problems/display-the-first-three-rows)

[中文文档](/solution/2800-2899/2879.Display%20the%20First%20Three%20Rows/README.md)

## Description

<pre>
DataFrame: <code>employees</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| employee_id | int |
| name | object |
| department | object |
| salary | int |
+-------------+--------+
</pre>

<p>Write a solution to display the <strong>first <code>3</code> </strong>rows<strong> </strong>of this DataFrame.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:
</strong>DataFrame employees
+-------------+-----------+-----------------------+--------+
| employee_id | name | department | salary |
+-------------+-----------+-----------------------+--------+
| 3 | Bob | Operations | 48675 |
| 90 | Alice | Sales | 11096 |
| 9 | Tatiana | Engineering | 33805 |
| 60 | Annabelle | InformationTechnology | 37678 |
| 49 | Jonathan | HumanResources | 23793 |
| 43 | Khaled | Administration | 40454 |
+-------------+-----------+-----------------------+--------+
<strong>Output:</strong>
+-------------+---------+-------------+--------+
| employee_id | name | department | salary |
+-------------+---------+-------------+--------+
| 3 | Bob | Operations | 48675 |
| 90 | Alice | Sales | 11096 |
| 9 | Tatiana | Engineering | 33805 |
+-------------+---------+-------------+--------+
<strong>Explanation:</strong>
Only the first 3 rows are displayed.</pre>

## Solutions

<!-- tabs:start -->

### **Pandas**

```python

```

### **...**

```

```

<!-- tabs:end -->
Loading