From 66cc234d2a0fab15cabb39dea63d90a5241cf40e Mon Sep 17 00:00:00 2001 From: Alok Tiwari Date: Wed, 9 Jul 2025 13:30:51 -0500 Subject: [PATCH] Pandas 2Completed --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 59f10e2..e5cf49e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,33 @@ # Pandas2 1 Problem 1 : Article Views I ( https://leetcode.com/problems/article-views-i/ ) +Write a solution to find all the authors that viewed at least one of their own articles. + +Return the result table sorted by id in ascending order. + +The result format is in the following example. +------------------------------------------------ +import pandas as pd + +def article_views(views: pd.DataFrame) -> pd.DataFrame: + df = views[views['author_id'] == views['viewer_id']] + return df[['author_id']].drop_duplicates().rename(columns={'author_id': 'id'}) + + + 2 Problem 2 :Invalid Tweets ( https://leetcode.com/problems/invalid-tweets/ ) +Write a solution to find the IDs of the invalid tweets. The tweet is invalid if the number of characters used in the content of the tweet is strictly greater than 15. + +Return the result table in any order. + +The result format is in the following example. + +------------------------------------------------ +import pandas as pd +def invalid_tweets(tweets: pd.DataFrame) -> pd.DataFrame: + return tweets[tweets['content'].str.len() > 15][['tweet_id']]