In [41]:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
In [42]:
keyEN = ['red', 'yellow', 'green', 'blue', 'black']
keyFR1 = ['rouge', 'jaune', 'vert', 'bleu', 'noir']
keyFR2 = ['jaune', 'vert', 'bleu', 'noir', 'rouge']
keyDE = ['gelb', 'gruen', 'blau', 'schwartz', 'rot']
In [43]:
dataENFR = pd.DataFrame({'keyEN' : keyEN, 'keyFR' : keyFR1})
dataENFR
Out[43]:
In [44]:
dataFRDE = pd.DataFrame({'keyFR' : keyFR2, 'keyDE' : keyDE})
dataFRDE
Out[44]:
In [45]:
simpleMerge = pd.merge(dataENFR, dataFRDE, on='keyFR', how='outer')
simpleMerge
Out[45]:
In [69]:
users = ['Tom', 'Tom', 'Tom',
'Bill', 'Bill', 'Bill', 'Bill',
'Jack',
'Bob',
'Jim']
sessionsUsers = ['sessionTom1', 'sessionTom2', 'sessionTom3',
'sessionBill1', 'sessionBill2', 'sessionBill3', 'sessionBill4',
'sessionJack',
'sessionBob',
'sessionJim']
sessionsChapters = [
'sessionTom1', 'sessionTom1', 'sessionTom1',
'sessionTom2', 'sessionTom2',
'sessionTom3',
'sessionBill1',
'sessionBill2', 'sessionBill2',
'sessionBill3', 'sessionBill3', 'sessionBill3',
'sessionBill4', 'sessionBill4', 'sessionBill4', 'sessionBill4',
'sessionJack', 'sessionJack', 'sessionJack',
'sessionBob',
'sessionJim']
chaptersSessions = ['1', '2', '3',
'1', '2',
'1',
'1',
'2', '3',
'4', '5', '6',
'5', '6', '5', '6',
'9', '10', '11',
'10',
'1']
times = 100 * np.random.rand(len(chaptersSessions))
times.sort()
times
Out[69]:
In [47]:
dataUsers = pd.DataFrame({'users' : users, 'sessions' : sessionsUsers})
#dataUsers
In [70]:
dataChapters = pd.DataFrame({'sessions' : sessionsChapters, 'chapters' : chaptersSessions, 'times' : times})
#dataChapters
In [71]:
complexMerge = pd.merge(dataUsers, dataChapters, on='sessions', how='outer')
complexMerge
Out[71]:
In [74]:
usersChapters = complexMerge.drop('sessions', 1)
In [82]:
usersChapters.groupby('users').max()
Out[82]: