import pandas as pd
df = pd.read_csv('jams.csv')
id = pd.Series(df['user_id'].unique())
id
/shared-libs/python3.7/py-core/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3170: DtypeWarning: Columns (7) have mixed types.Specify dtype option on import or set low_memory=False.
interactivity=interactivity, compiler=compiler, result=result)
ids = id.sample(1500)
idlist = ids.tolist()
idlist
dfjam = df.loc[df.user_id.isin(idlist)]
dfjam
del dfjam['jam_id']
del dfjam['creation_date']
del dfjam['link']
del dfjam['spotify_uri']
del dfjam['Unnamed: 7']
dfjam
dfjam['song'] = dfjam['title'] + ' by ' + dfjam['artist']
dfjam['user'] = dfjam['user_id']
del dfjam['user_id']
del dfjam['title']
del dfjam['artist']
dfjam
/shared-libs/python3.7/py-core/lib/python3.7/site-packages/ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
"""Entry point for launching an IPython kernel.
/shared-libs/python3.7/py-core/lib/python3.7/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy