From 28916fb86358088068ee2b1504c424049e582ed3 Mon Sep 17 00:00:00 2001 From: Haswatha Sridharan Date: Tue, 16 Sep 2025 19:39:38 -0500 Subject: [PATCH] Pandas2 Completed --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 59f10e2..a64b179 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,21 @@ # Pandas2 1 Problem 1 : Article Views I ( https://leetcode.com/problems/article-views-i/ ) +Solution: +import pandas as pd + +def article_views(views: pd.DataFrame) -> pd.DataFrame: + + df = views[views["author_id"] == views["viewer_id"]] + df.drop_duplicates(subset = "author_id", inplace = True) + return df[["author_id"]].rename(columns = {'author_id' : 'id'}).sort_values(by = 'id') 2 Problem 2 :Invalid Tweets ( https://leetcode.com/problems/invalid-tweets/ ) +Solution: + +import pandas as pd + +def invalid_tweets(tweets: pd.DataFrame) -> pd.DataFrame: + return tweets[tweets["content"].str.len() > 15][["tweet_id"]]