<jupyter_start><jupyter_text>2 dzien<jupyter_code>movies = pd.read_csv('ml-1m/movies.dat',sep='::', engine='python', names=['MovieID','Title','Genres'])
users = pd.read_csv('ml-1m/users.dat',sep='::', engine='python', names=['UserID','Gender','Age','Occupation','Zip-code'])
ratings = pd.read_csv('ml-1m/ratings.dat',sep='::', engine='python', names=['UserID','MovieID','Rating','Timestamp'])
movies
movies['Year'] = movies.Title.str.slice(-5,-1).astype(int)
movies
movies.Title.str.extract(r'\(\d{4}\)$')
movies['Title'] = movies.Title.str.slice(0,-6)
movies
movies.shape
len(movies)
movies[movies.Title.duplicated()]
counts = movies.groupby('Title').size()
counts[counts>1]
counts = movies.Title.value_counts() 
counts[counts>1]
duplicats = movies[movies.Title.duplicated(keep=False)]
duplicats = duplicats.groupby('Title')['Year'].agg(['max', 'min'])
(duplicats['max'] - duplicats['min']).max()
movies.groupby('Year').size()
movies.Year.value_counts()
pd.DataFrame(users.groupby(['Gender','Age']).size()).rename({0: 'COUNT'}, axis=1)
pd.crosstab(users.Gender, users.Age, margins=True)   
pd.crosstab(users.Gender, users.Age, normalize='all')   
pd.pivot_table(users['Gender','Age'],index=['Gender','Age'])
splited = movies.Genres.str.split('|',expand=True)
splited.stack().reset_index().groupby(0).size()
splited.stack().value_counts()
movies.Genres.str.get_dummies(sep='|').sum()
one = ratings.merge(movies)
one.groupby('Title')['Rating'].mean().sort_values(ascending=False)
one = ratings.merge(movies)
one.groupby('Title')['Rating'].agg(['size', 'mean']).sort_values(by='mean',ascending=False).query("size>100").head()

one = ratings.merge(users)
two = one.groupby(['MovieID','Gender'])['Rating'].agg(['size', 'mean']).sort_values(by='mean',ascending=False).reset_index().query('size>100')
pd.merge(movies, two, left_on='MovieID', right_index=True).drop_duplicates(subset="Gender")
oceny_users_movies = pd.merge(pd.merge(ratings,users), movies)
oceny_users_movies.groupby('Age').Year.mean()
import tqdm
for i in tqdm.tqdm_notebook(range(15)):
    n = 4000
    a = np.random.uniform(0,1,(n, n))
    b = np.random.uniform(0,1,(n, n))
    c = a @ b<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23486238532110093, 'fraction_numerical': 0.013761467889908258, 'mean_word_length': 8.320512820512821, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '425572', 'license': 'Apache-2.0', 'n_tokens_mistral': 865, 'n_tokens_neox': 829, 'n_words': 91, 'path': 'Pandas - examples.ipynb', 'repo_name': 'SebastianKikas/Bootcamp', 'size': '2180'}