Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tilana committed Jul 21, 2024
1 parent 7fd2e28 commit 529ed34
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 167 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down
8 changes: 8 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: research-env
channels:
- defaults
dependencies:
- numpy
- pandas
- matplotlib
- pyalex
198 changes: 32 additions & 166 deletions recipies/preprints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -45,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -56,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -82,7 +100,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -103,7 +121,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -143,146 +161,13 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>title</th>\n",
" <th>publication_date</th>\n",
" <th>doi</th>\n",
" <th>cited</th>\n",
" <th>authors</th>\n",
" <th>locations</th>\n",
" <th>location_count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>https://openalex.org/W4318909870</td>\n",
" <td>Overcoming Vaccine Skepticism in Pakistan: A C...</td>\n",
" <td>2023-02-02</td>\n",
" <td>https://doi.org/10.5281/zenodo.7597141</td>\n",
" <td>12</td>\n",
" <td>Bibi Aisha Sadiqa</td>\n",
" <td>submittedVersion: European Organization for Nu...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>https://openalex.org/W4386199227</td>\n",
" <td>Clinical Rationale for SARS-CoV-2 Base Spike P...</td>\n",
" <td>2023-08-25</td>\n",
" <td>https://doi.org/10.5281/zenodo.8286460</td>\n",
" <td>5</td>\n",
" <td>Peter A. McCullough, Cade Wynn, Brian C Procter</td>\n",
" <td>submittedVersion: European Organization for Nu...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>https://openalex.org/W3197911323</td>\n",
" <td>The Political Economy of a Modern Pandemic: As...</td>\n",
" <td>2023-07-24</td>\n",
" <td>https://doi.org/10.32920/23739360.v1</td>\n",
" <td>4</td>\n",
" <td>John Shields, Zainab Abu Alrob</td>\n",
" <td>submittedVersion - https://doi.org/10.32920/23...</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>https://openalex.org/W4307231237</td>\n",
" <td>Higher risk of short term COVID-19 vaccine adv...</td>\n",
" <td>2023-05-02</td>\n",
" <td>https://doi.org/10.1093/rheumatology/keac603</td>\n",
" <td>3</td>\n",
" <td>Mrinalini Dey, R Naveen, Elena Nikiphorou, Par...</td>\n",
" <td>submittedVersion: National Institutes of Healt...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>https://openalex.org/W4319655309</td>\n",
" <td>Navigating the Post-COVID Market: A Prospectiv...</td>\n",
" <td>2023-02-09</td>\n",
" <td>https://doi.org/10.5281/zenodo.7625190</td>\n",
" <td>3</td>\n",
" <td>Peng Sun, Xiaode Zuo</td>\n",
" <td>submittedVersion: European Organization for Nu...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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()"
]
},
Expand All @@ -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"
Expand Down

0 comments on commit 529ed34

Please sign in to comment.