cleaner column filtering without loc calls

This commit is contained in:
andy 2021-05-11 00:17:56 +01:00
parent a33060c0d3
commit faeda66041
7 changed files with 7389 additions and 154 deletions

File diff suppressed because one or more lines are too long

View File

@ -727,7 +727,7 @@
],
"source": [
"# select only descriptor float columns\n",
"filtered_scrobbles = scrobbles.loc[:, float_headers]\n",
"filtered_scrobbles = scrobbles[float_headers]\n",
"# resample by month and mean\n",
"filtered_scrobbles = filtered_scrobbles.resample(\"3W\").mean()\n",
"\n",
@ -750,7 +750,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"outputs": [
{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -59,7 +59,7 @@
"# distinct on uri\n",
"filtered_playlists = [i.drop_duplicates(['uri']) for i in filtered_playlists]\n",
"# select only descriptor float columns\n",
"filtered_playlists = [i.loc[:, headers] for i in filtered_playlists]"
"filtered_playlists = [i[headers] for i in filtered_playlists]"
]
},
{

View File

@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@ -209,7 +209,7 @@
"max 5.000000 0.962000 "
]
},
"execution_count": 18,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@ -241,7 +241,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@ -274,7 +274,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@ -291,7 +291,7 @@
}
],
"source": [
"playlist_frame.set_index('time').loc[:, float_headers].resample(\"2W\").mean().plot(lw=3)\n",
"playlist_frame.set_index('time')[float_headers].resample(\"2W\").mean().plot(lw=3)\n",
"\n",
"plt.title(f\"{playlist_name} Characteristics Over Time\")\n",
"plt.legend(loc = \"upper left\", fontsize = \"x-small\")\n",
@ -311,7 +311,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@ -339,7 +339,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@ -361,7 +361,7 @@
"# distinct on uri\n",
"filtered_playlists = [i.drop_duplicates(['uri']) for i in filtered_playlists]\n",
"# select only descriptor float columns\n",
"filtered_playlists = [i.loc[:, float_headers] for i in filtered_playlists]\n",
"filtered_playlists = [i[float_headers] for i in filtered_playlists]\n",
"\n",
"playlist_mean = [i.mean() for i in filtered_playlists]\n",
"playlist_std = [i.std() for i in filtered_playlists]"
@ -376,7 +376,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@ -414,7 +414,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@ -454,7 +454,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@ -521,7 +521,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [

File diff suppressed because one or more lines are too long