<jupyter_start><jupyter_text><jupyter_code>!pip install kaggle
from google.colab import files
files.upload()
!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!chmod 600 ~/.kaggle/kaggle.json
!kaggle datasets download -d gspmoreira/articles-sharing-reading-from-cit-deskdrop
!ls
!unzip  articles-sharing-reading-from-cit-deskdrop.zip
!ls
import pandas as pd
import numpy as np

df1=pd.read_csv("shared_articles.csv")
df2=pd.read_csv("users_interactions.csv")
df1.head()
df2.head()
#Project 139
df1=df1[df1["eventType"]=="CONTENT SHARED"]
df1.head()
df2.shape
df1.shape
def find_total_event (df1_row):
  total_likes=df2[(df2["contentId"]==df1_row["contentId"])& (df2["eventType"]=="LIKE")].shape[0]
  total_views=df2[(df2["contentId"]==df1_row["contentId"])& (df2["eventType"]=="VIEW")].shape[0]
  total_bookmarks=df2[(df2["contentId"]==df1_row["contentId"])& (df2["eventType"]=="BOOKMARK")].shape[0]
  total_follows=df2[(df2["contentId"]==df1_row["contentId"])& (df2["eventType"]=="FOLLOW")].shape[0]
  total_comments=df2[(df2["contentId"]==df1_row["contentId"])& (df2["eventType"]=="COMMENT CREATED")].shape[0]
  return total_likes+total_views+total_bookmarks+total_comments+total_follows
df1["total_events"]=df1.apply(find_total_event,axis=1)
df1.head()
df1=df1.sort_values(["total_events"],ascending=[False])
df1.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19718309859154928, 'fraction_numerical': 0.0363232023721275, 'mean_word_length': 9.975609756097562, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '243751', 'license': 'MIT', 'n_tokens_mistral': 571, 'n_tokens_neox': 553, 'n_words': 65, 'path': 'Project_C139.ipynb', 'repo_name': 'Yuwin2008/Importing-Data-From-Kaggle-2', 'size': '1349'}