Skip to content

Commit

Permalink
Preserve old ERDDAP.to_pandas behaviour
Browse files Browse the repository at this point in the history
  This ensures backwards-compatibility with the ERDDAP class.

  - Use old ERDDAP.to_pandas(**kw) behaviour
  - Revert 90389be which modified test_to_objects
  • Loading branch information
vinisalazar committed Dec 12, 2022
1 parent 14795ea commit 73128a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
14 changes: 4 additions & 10 deletions erddapy/erddapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,7 @@ def get_download_url(
**kwargs,
)

def to_pandas(
self,
requests_kwargs: Optional[Dict] = None,
pandas_kwargs: Optional[Dict] = None,
):
def to_pandas(self, **kw):
"""Save a data request to a pandas.DataFrame.
Accepts any `pandas.read_csv` keyword arguments, passed as a dictionary to pandas_kwargs.
Expand All @@ -346,11 +342,9 @@ def to_pandas(
[1] Download a ISO-8859-1 .csv file with line 1: name (units). Times are ISO 8601 strings.
"""
if requests_kwargs is None:
requests_kwargs = {}
response = requests_kwargs.pop("response", "csvp")
url = self.get_download_url(response=response, **requests_kwargs)
return to_pandas(url, requests_kwargs, pandas_kwargs)
response = kw.pop("response", "csvp")
url = self.get_download_url(response=response, **kw)
return to_pandas(url, pandas_kwargs=dict(**kw))

def to_ncCF(self, protocol: str = None, **kw):
"""Load the data request into a Climate and Forecast compliant netCDF4-python object."""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_to_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def test_to_pandas(dataset_tabledap):
import pandas as pd

df = dataset_tabledap.to_pandas(
pandas_kwargs={"index_col": "time (UTC)", "parse_dates": True},
index_col="time (UTC)",
parse_dates=True,
).dropna()

assert isinstance(df, pd.DataFrame)
Expand Down

0 comments on commit 73128a7

Please sign in to comment.