Skip to content

Commit

Permalink
Lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
evamaxfield committed Mar 4, 2024
1 parent e9686b0 commit cd02545
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions award_pynder/sources/sloan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import logging
import time
from datetime import datetime
import requests

import pandas as pd
import requests
from tqdm import tqdm
from bs4 import BeautifulSoup
from tqdm import tqdm

from .base import ALL_DATASET_FIELDS, DatasetFields, DataSource

Expand Down Expand Up @@ -89,7 +88,10 @@ def _query_total_grants(
soup.find(
"td",
class_="results-count",
).text.replace(",", "").replace("Grants", "").strip()
)
.text.replace(",", "")
.replace("Grants", "")
.strip()
)

except Exception as e:
Expand Down Expand Up @@ -132,7 +134,8 @@ def _get_chunk(
amount = header.find("div", class_="amount").text
amount = float(
amount.replace("amount: ", "")
.replace("$", "").replace(",", "")
.replace("$", "")
.replace(",", "")
.strip()
)

Expand All @@ -144,7 +147,9 @@ def _get_chunk(
details = li.find("div", class_="details")

# Collect the description (stored in the div "brief-description")
description = details.find("div", class_="brief-description").text.strip()
description = details.find(
"div", class_="brief-description"
).text.strip()

# Collect the id (stored in the div attribute
# "data-accordian-group" for div with class "details")
Expand All @@ -159,12 +164,12 @@ def _get_chunk(

# Take all of the text from the second ul
sub_program_and_pi = grid.find_all("ul")[1].text.strip()

# Find the index of the word "Investigator"
pi_index = sub_program_and_pi.find("Investigator")

# Only keep text after the word "Investigator"
pi = sub_program_and_pi[pi_index + len("Investigator"):].strip()
pi = sub_program_and_pi[pi_index + len("Investigator") :].strip()

# Add row
rows.append(
Expand Down Expand Up @@ -260,7 +265,7 @@ def get_data(
# Concatenate the chunks
if len(chunks) == 0:
return pd.DataFrame(columns=ALL_DATASET_FIELDS)

# Concat and filter out years not in range
df = pd.concat(chunks, ignore_index=True).reset_index(drop=True)
if from_datetime:
Expand Down

0 comments on commit cd02545

Please sign in to comment.