Skip to content

Commit

Permalink
Merge branch 'release-1.7.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Milind220 committed Apr 25, 2022
2 parents a3aafe9 + 33b0142 commit 57530e9
Show file tree
Hide file tree
Showing 49 changed files with 22,598 additions and 11,048 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ozon3
version = 1.7.4
version = 1.7.5
author = Milind Sharma
author_email = milindsharma8@gmail.com
description = A package to get air quality data using the WAQI API
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
description="A package to get air quality data using the WAQI API",
license="GPLv3+",
url="https://github.com/Milind220/Ozone",
version="1.7.4",
download_url="https://github.com/Milind220/Ozone/archive/refs/tags/v1.7.4.tar.gz",
version="1.7.5",
download_url="https://github.com/Milind220/Ozone/archive/refs/tags/v1.7.5.tar.gz",
packages=setuptools.find_packages(),
install_requires=[
"numpy; python_version>='3'",
Expand Down
18 changes: 13 additions & 5 deletions src/ozone/ozone.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def __init__(

if self.file_name == "air_quality":
warnings.warn(
"You have not specified a custom save file name. Existing files with the same name may be overwritten!"
"You have not specified a custom save file name. "
"Existing files with the same name may be overwritten!"
)

def _check_token_validity(self) -> None:
Expand Down Expand Up @@ -160,6 +161,11 @@ def _format_output(
if data_format == "df":
return df

if data_format not in ["csv", "xlsx", "json"]:
raise Exception(
f"Invalid file format {data_format}. Use any of: csv, json, xlsx, df"
)

self.output_dir_path.mkdir(exist_ok=True)

if data_format == "csv":
Expand All @@ -179,10 +185,7 @@ def _format_output(
print(
f"File saved to disk at {self.output_dir_path} as {self.file_name}.xlsx"
)
else:
raise Exception(
f"Invalid file format {data_format}. Use any of: csv, json, xlsx, df"
)

return pandas.DataFrame()

def _extract_live_data(
Expand Down Expand Up @@ -246,7 +249,12 @@ def _extract_forecast_data(self, data_obj: Any) -> pandas.DataFrame:
dict_of_frames[pol] = pandas.DataFrame(lst).set_index("day")

df = pandas.concat(dict_of_frames, axis=1)

# Convert to numeric while making non-numerics nan,
# and then convert to float, just in case there's int
df = df.apply(lambda x: pandas.to_numeric(x, errors="coerce")).astype(float)
df.index = pandas.to_datetime(df.index)
df = df.reset_index().rename(columns={"day": "date"})
return df

def _check_and_get_data_obj(
Expand Down
76 changes: 0 additions & 76 deletions tests/cassettes/test_get_city_air/test_bad_data_format.yaml

This file was deleted.

224 changes: 0 additions & 224 deletions tests/cassettes/test_get_city_air/test_correct_data_format.yaml

This file was deleted.

Loading

0 comments on commit 57530e9

Please sign in to comment.