Skip to content

Replace deprecated delim_whitespace parameter to sep='\s+' in pd.read_csv #2932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _load_japan_quakes():
return pd.read_csv(
fname,
header=1,
delim_whitespace=True,
sep=r"\s+",
names=[
"year",
"month",
Expand All @@ -52,7 +52,7 @@ def _load_ocean_ridge_points():
fname = which("@ridge.txt", download="c")
return pd.read_csv(
fname,
delim_whitespace=True,
sep=r"\s+",
names=["longitude", "latitude"],
skiprows=1,
comment=">",
Expand Down Expand Up @@ -102,9 +102,7 @@ def _load_fractures_compilation():
the fractures.
"""
fname = which("@fractures_06.txt", download="c")
data = pd.read_csv(
fname, header=None, delim_whitespace=True, names=["azimuth", "length"]
)
data = pd.read_csv(fname, header=None, sep=r"\s+", names=["azimuth", "length"])
return data[["length", "azimuth"]]


Expand Down Expand Up @@ -167,7 +165,7 @@ def _load_rock_sample_compositions():
fname = which("@ternary.txt", download="c")
return pd.read_csv(
fname,
delim_whitespace=True,
sep=r"\s+",
header=None,
names=["limestone", "water", "air", "permittivity"],
)
Expand All @@ -183,7 +181,7 @@ def _load_notre_dame_topography():
The data table with columns "x", "y", and "z".
"""
fname = which("@Table_5_11.txt", download="c")
return pd.read_csv(fname, delim_whitespace=True, header=None, names=["x", "y", "z"])
return pd.read_csv(fname, sep=r"\s+", header=None, names=["x", "y", "z"])


def _load_maunaloa_co2():
Expand All @@ -197,7 +195,7 @@ def _load_maunaloa_co2():
"""
fname = which("@MaunaLoa_CO2.txt", download="c")
return pd.read_csv(
fname, header=None, skiprows=1, delim_whitespace=True, names=["date", "co2_ppm"]
fname, header=None, skiprows=1, sep=r"\s+", names=["date", "co2_ppm"]
)


Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def fixture_data():
"""
Load the point data from the test file.
"""
return pd.read_table(POINTS_DATA, header=None, delim_whitespace=True)
return pd.read_table(POINTS_DATA, header=None, sep=r"\s+")


@pytest.fixture(scope="module", name="region")
Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_grdtrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fixture_dataframe():
Load a pandas DataFrame with points.
"""
return pd.read_csv(
POINTS_DATA, delim_whitespace=True, header=None, names=["longitude", "latitude"]
POINTS_DATA, sep=r"\s+", header=None, names=["longitude", "latitude"]
)


Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def fixture_data():
"""
fname = which("@Table_5_11_mean.xyz", download="c")
return pd.read_csv(
fname, delim_whitespace=True, header=None, names=["x", "y", "z"], skiprows=1
fname, sep=r"\s+", header=None, names=["x", "y", "z"], skiprows=1
)


Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_triangulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def fixture_dataframe():
"""
fname = which("@Table_5_11_mean.xyz", download="c")
return pd.read_csv(
fname, delim_whitespace=True, header=None, names=["x", "y", "z"], skiprows=1
fname, sep=r"\s+", header=None, names=["x", "y", "z"], skiprows=1
)[:10]


Expand Down