Struktur Data di Python

source : adapted from https://www.datacamp.com/community/tutorials/data-structures-python

1. Data Frame

##### Groupby
df[['userid','city']].groupby(['city']).count()
df[['userid','city']].groupby(['city']).sum()
df[['userid','city']].groupby(['city']).mean()
##### Join
pd.merge(df1,df2,on='userid',how='inner')
df1.merge(df2,left_on='userid',right_on='id',how='inner')
##### Union
pd.concat([df1,df2],axis=0,ignore_index=True) # union by rows
pd.concat([df1,df2],axis=1,ignore_index=True) # union by columns
##### IN, NOT IN
df[df.relid.isin(userid)] # IN userid list
df[~df.relid.isin(userid)] # NOT IN userid list

2. List

'org' in ['com','id','org']
[1,2,3] + [4,5]
['abc','def']*4
index()
count()
sort()
append()
[k for k in temp if k not in ['a','b']]
["hello" for _ in range(len(adj))]
zip(seq1,seq2)

3. Dictionary (Dict)

4. Set

5. Tuple

6. Array

Refference :

--

--

--

Data Scientist Jagoan Hosting. Visit my website at www.arofiqimaulana.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
A.Rofiqi Maulana

A.Rofiqi Maulana

Data Scientist Jagoan Hosting. Visit my website at www.arofiqimaulana.com

More from Medium

SPCA Scraper

Introduction of MadCanner

For Father’s Day

Project 3 Process