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 3229152

Browse files
Update readme.md
1 parent b10b65c commit 3229152

File tree

1 file changed

+38
-0
lines changed
  • LeetCode SQL 50 Solution/1729. Find Followers Count

1 file changed

+38
-0
lines changed

‎LeetCode SQL 50 Solution/1729. Find Followers Count/readme.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Here's an improved `README.md` with a **Python (Pandas) solution** alongside the **SQL solution**:
2+
3+
```md
14
# 📊 Find Followers Count - LeetCode 1729
25

36
## 📌 Problem Statement
@@ -64,16 +67,51 @@ ORDER BY user_id;
6467

6568
---
6669

70+
## 🐍 Python (Pandas) Solution
71+
72+
### **Approach:**
73+
1. Use `groupby("user_id")` to count followers for each user.
74+
2. Use `reset_index(name="followers_count")` to format the result properly.
75+
3. Sort the result by `user_id`.
76+
77+
```python
78+
import pandas as pd
79+
80+
def find_followers_count(followers: pd.DataFrame) -> pd.DataFrame:
81+
result = (
82+
followers.groupby("user_id")["follower_id"]
83+
.count()
84+
.reset_index(name="followers_count")
85+
.sort_values("user_id")
86+
)
87+
return result
88+
```
89+
90+
---
91+
6792
## 📁 File Structure
6893
```
6994
📂 Find-Followers-Count
7095
│── 📜 README.md
7196
│── 📜 solution.sql
97+
│── 📜 solution.py
7298
│── 📜 test_cases.sql
99+
│── 📜 test_cases.csv
73100
```
74101

75102
---
76103

77104
## 🔗 Useful Links
78105
- 📖 [LeetCode Problem](https://leetcode.com/problems/find-followers-count/)
79106
- 📝 [MySQL COUNT Function](https://www.w3schools.com/sql/sql_count.asp)
107+
- 🐍 [Pandas GroupBy](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html)
108+
```
109+
110+
---
111+
112+
### 🚀 **What's New in this Version?**
113+
✅ **Added Python (Pandas) Solution**
114+
✅ **Structured File Organization**
115+
✅ **Includes Helpful Links for Learning**
116+
117+
Would you like any further enhancements? 🚀

0 commit comments

Comments
(0)

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