From 529ed34c16b611706f165e556f03434fadcb7ba8 Mon Sep 17 00:00:00 2001 From: tilana Date: Sun, 21 Jul 2024 17:59:53 +0200 Subject: [PATCH] update code --- _config.yml | 2 +- environment.yml | 8 ++ recipies/preprints.ipynb | 198 +++++++-------------------------------- 3 files changed, 41 insertions(+), 167 deletions(-) create mode 100644 environment.yml diff --git a/_config.yml b/_config.yml index 613bb79..dca0e17 100644 --- a/_config.yml +++ b/_config.yml @@ -13,7 +13,6 @@ latex: # Information about where the book exists on the web repository: url: https://github.com/InvestigatingScience/research_recipies_workbook - path_to_book: docs branch: main # Add GitHub buttons to your book @@ -23,6 +22,7 @@ html: launch_buttons: colab_url: "https://colab.research.google.com" binderhub_url: "https://mybinder.org" + #binderhub_url: https://mybinder.org/v2/gh/InvestigatingScience/research_recipies_workbook/main?filepath={path}" thebe: true diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..a5ede4d --- /dev/null +++ b/environment.yml @@ -0,0 +1,8 @@ +name: research-env +channels: + - defaults +dependencies: + - numpy + - pandas + - matplotlib + - pyalex diff --git a/recipies/preprints.ipynb b/recipies/preprints.ipynb index 56c2ff9..ba38b99 100644 --- a/recipies/preprints.ipynb +++ b/recipies/preprints.ipynb @@ -14,24 +14,42 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 1. Load libraries & define helper functions" + "## 1. Load libraries" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install pandas\n", + "!pip install pyalex" + ] + }, + { + "cell_type": "code", + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pyalex import Works, Authors, Sources, Institutions, Concepts, Publishers, Funders\n", "from itertools import chain\n", "import pandas as pd\n", - "import pyalex" + "import pyalex\n", + "import os" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Define helper functions" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -45,7 +63,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -56,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -82,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -103,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -143,146 +161,13 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
idtitlepublication_datedoicitedauthorslocationslocation_count
0https://openalex.org/W4318909870Overcoming Vaccine Skepticism in Pakistan: A C...2023-02-02https://doi.org/10.5281/zenodo.759714112Bibi Aisha SadiqasubmittedVersion: European Organization for Nu...1
1https://openalex.org/W4386199227Clinical Rationale for SARS-CoV-2 Base Spike P...2023-08-25https://doi.org/10.5281/zenodo.82864605Peter A. McCullough, Cade Wynn, Brian C ProctersubmittedVersion: European Organization for Nu...1
2https://openalex.org/W3197911323The Political Economy of a Modern Pandemic: As...2023-07-24https://doi.org/10.32920/23739360.v14John Shields, Zainab Abu AlrobsubmittedVersion - https://doi.org/10.32920/23...2
3https://openalex.org/W4307231237Higher risk of short term COVID-19 vaccine adv...2023-05-02https://doi.org/10.1093/rheumatology/keac6033Mrinalini Dey, R Naveen, Elena Nikiphorou, Par...submittedVersion: National Institutes of Healt...1
4https://openalex.org/W4319655309Navigating the Post-COVID Market: A Prospectiv...2023-02-09https://doi.org/10.5281/zenodo.76251903Peng Sun, Xiaode ZuosubmittedVersion: European Organization for Nu...1
\n", - "
" - ], - "text/plain": [ - " id \\\n", - "0 https://openalex.org/W4318909870 \n", - "1 https://openalex.org/W4386199227 \n", - "2 https://openalex.org/W3197911323 \n", - "3 https://openalex.org/W4307231237 \n", - "4 https://openalex.org/W4319655309 \n", - "\n", - " title publication_date \\\n", - "0 Overcoming Vaccine Skepticism in Pakistan: A C... 2023-02-02 \n", - "1 Clinical Rationale for SARS-CoV-2 Base Spike P... 2023-08-25 \n", - "2 The Political Economy of a Modern Pandemic: As... 2023-07-24 \n", - "3 Higher risk of short term COVID-19 vaccine adv... 2023-05-02 \n", - "4 Navigating the Post-COVID Market: A Prospectiv... 2023-02-09 \n", - "\n", - " doi cited \\\n", - "0 https://doi.org/10.5281/zenodo.7597141 12 \n", - "1 https://doi.org/10.5281/zenodo.8286460 5 \n", - "2 https://doi.org/10.32920/23739360.v1 4 \n", - "3 https://doi.org/10.1093/rheumatology/keac603 3 \n", - "4 https://doi.org/10.5281/zenodo.7625190 3 \n", - "\n", - " authors \\\n", - "0 Bibi Aisha Sadiqa \n", - "1 Peter A. McCullough, Cade Wynn, Brian C Procter \n", - "2 John Shields, Zainab Abu Alrob \n", - "3 Mrinalini Dey, R Naveen, Elena Nikiphorou, Par... \n", - "4 Peng Sun, Xiaode Zuo \n", - "\n", - " locations location_count \n", - "0 submittedVersion: European Organization for Nu... 1 \n", - "1 submittedVersion: European Organization for Nu... 1 \n", - "2 submittedVersion - https://doi.org/10.32920/23... 2 \n", - "3 submittedVersion: National Institutes of Healt... 1 \n", - "4 submittedVersion: European Organization for Nu... 1 " - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df = pd.DataFrame.from_dict(preprints)\n", - "df.to_csv(f'../results/openalex_preprints_{year}_{n_max}.csv')\n", - "df.to_excel(f'../results/openalex_preprints_{year}_{n_max}.xlsx')\n", + "os.makedirs('./results', exist_ok=True)\n", + "df.to_csv(f'./results/openalex_preprints_{year}_{n_max}.csv')\n", "df.head()" ] }, @@ -295,28 +180,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "id https://openalex.org/W1485155423\n", - "title For Hunger-proof Cities: Sustainable Urban Foo...\n", - "publication_date 2023-09-05\n", - "doi https://doi.org/10.32920/24084468.v1\n", - "cited 204\n", - "authors Mustafa KoƧ, Rod MacRae, L. J. A. Mougeot, J. ...\n", - "locations submittedVersion - https://doi.org/10.32920/24...\n", - "location_count 1\n", - "Name: 0, dtype: object" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "paper = df.iloc[0]\n", "paper"