Skip to content

Commit baa4b1f

Browse files
committed
Remove shorthand import pandas as pd
1 parent c3b2bff commit baa4b1f

File tree

13 files changed

+44
-44
lines changed

13 files changed

+44
-44
lines changed

src/emsarray/cli/commands/extract_points.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
from pathlib import Path
44

5-
import pandas as pd
5+
import pandas
66

77
import emsarray
88
from emsarray.cli import BaseCommand, CommandException
@@ -64,7 +64,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
6464
def handle(self, options: argparse.Namespace) -> None:
6565
logger.info("Extracting points from %r", str(options.input_path))
6666
dataset = emsarray.open_dataset(options.input_path)
67-
dataframe = pd.read_csv(options.points)
67+
dataframe = pandas.read_csv(options.points)
6868

6969
try:
7070
point_data = point_extraction.extract_dataframe(

src/emsarray/operations/point_extraction.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from typing import Any, Hashable, List, Literal, Tuple
1818

1919
import numpy
20-
import pandas as pd
20+
import pandas
2121
import shapely
2222
import xarray
2323
import xarray.core.dtypes as xrdtypes
@@ -42,7 +42,7 @@ def __post_init__(self) -> None:
4242

4343

4444
def _dataframe_to_dataset(
45-
dataframe: pd.DataFrame,
45+
dataframe: pandas.DataFrame,
4646
*,
4747
dimension_name: Hashable,
4848
) -> xarray.Dataset:
@@ -109,7 +109,7 @@ def extract_points(
109109
points=[points[i] for i in out_of_bounds])
110110

111111
# Make a DataFrame out of all point indexers
112-
selector_df = pd.DataFrame([
112+
selector_df = pandas.DataFrame([
113113
convention.selector_for_index(index.index)
114114
for index in indexes
115115
if index is not None])
@@ -127,7 +127,7 @@ def extract_points(
127127

128128
def extract_dataframe(
129129
dataset: xarray.Dataset,
130-
dataframe: pd.DataFrame,
130+
dataframe: pandas.DataFrame,
131131
coordinate_columns: Tuple[str, str],
132132
*,
133133
point_dimension: Hashable = 'point',
@@ -178,11 +178,11 @@ def extract_dataframe(
178178
.. code-block:: python
179179
180180
import emsarray
181-
import pandas as pd
181+
import pandas
182182
from emsarray.operations import point_extraction
183183
184184
ds = emsarray.tutorial.open_dataset('gbr4')
185-
df = pd.DataFrame({
185+
df = pandas.DataFrame({
186186
'lon': [152.807, 152.670, 153.543],
187187
'lat': [-24.9595, -24.589, -25.488],
188188
'name': ['a', 'b', 'c'],

src/emsarray/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import cftime
2626
import netCDF4
2727
import numpy
28-
import pandas as pd
28+
import pandas
2929
import pytz
3030
import shapely
3131
import xarray
@@ -315,7 +315,7 @@ def fix_bad_time_units(dataset_or_array: Union[xarray.Dataset, xarray.DataArray]
315315
continue # Don't bother fixing this one - too broken
316316

317317
try:
318-
pd.Timestamp(timestamp)
318+
pandas.Timestamp(timestamp)
319319
continue # These units are formatted fine and don't need fixing
320320
except ValueError:
321321
pass

tests/cli/commands/test_extract_points.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pathlib
22

33
import numpy
4-
import pandas as pd
4+
import pandas
55
import pytest
66
import xarray
77
from numpy.testing import assert_allclose, assert_equal
@@ -24,7 +24,7 @@ def test_extract_points(
2424
θs = numpy.random.sample(num_points) * 2 * numpy.pi
2525
xs = numpy.cos(θs) * rs
2626
ys = numpy.sin(θs) * rs
27-
points_df = pd.DataFrame({'name': names, 'lon': xs, 'lat': ys})
27+
points_df = pandas.DataFrame({'name': names, 'lon': xs, 'lat': ys})
2828
points_df.to_csv(csv_path, index=False)
2929

3030
main(['extract-points', str(in_path), str(csv_path), str(out_path)])
@@ -63,7 +63,7 @@ def test_extract_points_out_of_bounds(
6363
csv_path = tmp_path / 'points.csv'
6464
out_path = tmp_path / 'out.nc'
6565

66-
points_df = pd.DataFrame({'lon': numpy.arange(10), 'lat': numpy.zeros(10)})
66+
points_df = pandas.DataFrame({'lon': numpy.arange(10), 'lat': numpy.zeros(10)})
6767
points_df.to_csv(csv_path, index=False)
6868
print(points_df.iloc[[4, 5, 6, 7, 8, 9]])
6969

tests/conventions/test_cfgrid1d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pathlib
55

66
import numpy
7-
import pandas as pd
7+
import pandas
88
import pytest
99
import xarray
1010
from matplotlib.figure import Figure
@@ -69,11 +69,11 @@ def make_dataset(
6969
)
7070

7171
time = xarray.DataArray(
72-
# Note: Using pd.date_range() directly here will lead to strange
72+
# Note: Using pandas.date_range() directly here will lead to strange
7373
# behaviours, where the `time` dimension becomes a data variable with
7474
# a datetime64 dtype. Using a list of datetimes instead seems to avoid
7575
# this, resulting in time simply being a dimension.
76-
data=list(pd.date_range("2021-11-11", periods=time_size)),
76+
data=list(pandas.date_range("2021-11-11", periods=time_size)),
7777
dims=[time_name],
7878
name=time_name,
7979
attrs={

tests/conventions/test_cfgrid2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from typing import Type
1414

1515
import numpy
16-
import pandas as pd
16+
import pandas
1717
import pytest
1818
import xarray
1919
from matplotlib.figure import Figure
@@ -86,7 +86,7 @@ def make_dataset(
8686
layers = ShocLayerGenerator(k=k_size)
8787

8888
time = xarray.DataArray(
89-
data=pd.date_range("2021-11-11", periods=time_size),
89+
data=pandas.date_range("2021-11-11", periods=time_size),
9090
dims=["time"],
9191
attrs={
9292
"long_name": "Time",

tests/conventions/test_shoc_standard.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Type
77

88
import numpy
9-
import pandas as pd
9+
import pandas
1010
import pytest
1111
import xarray
1212
from matplotlib.figure import Figure
@@ -82,11 +82,11 @@ def make_dataset(
8282
layers = ShocLayerGenerator(k=k_size)
8383

8484
t = xarray.DataArray(
85-
# Note: Using pd.date_range() directly here will lead to strange
85+
# Note: Using pandas.date_range() directly here will lead to strange
8686
# behaviours, where the `record` dimension becomes a data variable with
8787
# a datetime64 dtype. Using a list of datetimes instead seems to avoid
8888
# this, resulting in record simply being a dimension.
89-
data=list(pd.date_range("2021-11-11", periods=time_size)),
89+
data=list(pandas.date_range("2021-11-11", periods=time_size)),
9090
dims=["record"],
9191
attrs={
9292
"long_name": "Time",

tests/conventions/test_ugrid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import geojson
99
import numpy
10-
import pandas as pd
10+
import pandas
1111
import pytest
1212
import xarray
1313
from matplotlib.figure import Figure
@@ -178,11 +178,11 @@ def make_dataset(
178178
)
179179

180180
t = xarray.DataArray(
181-
# Note: Using pd.date_range() directly here will lead to strange
181+
# Note: Using pandas.date_range() directly here will lead to strange
182182
# behaviours, where the `record` dimension becomes a data variable with
183183
# a datetime64 dtype. Using a list of datetimes instead seems to avoid
184184
# this, resulting in record simply being a dimension.
185-
data=list(pd.date_range("2021-11-11", periods=time_size)),
185+
data=list(pandas.date_range("2021-11-11", periods=time_size)),
186186
dims=[time_dimension],
187187
name='t',
188188
attrs={

tests/masking/test_mask_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import netCDF4
66
import numpy
7-
import pandas as pd
7+
import pandas
88
import pytest
99
import shapely.geometry
1010
import xarray
@@ -127,7 +127,7 @@ def test_mask_dataset(tmp_path: pathlib.Path):
127127
)
128128

129129
t = xarray.DataArray(
130-
data=list(pd.date_range("2021-11-11", periods=records)),
130+
data=list(pandas.date_range("2021-11-11", periods=records)),
131131
dims=["record"],
132132
attrs={
133133
"long_name": "Time",

tests/operations/depth/test_ocean_floor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy
2-
import pandas as pd
2+
import pandas
33
import pytest
44
import xarray
55
from numpy.testing import assert_equal
@@ -27,7 +27,7 @@ def test_ocean_floor():
2727
dataset = xarray.Dataset(
2828
data_vars={"temp": temp},
2929
coords={
30-
'time': (['t'], pd.date_range('2022-02-08', periods=5)),
30+
'time': (['t'], pandas.date_range('2022-02-08', periods=5)),
3131
'lon': (['x'], -numpy.arange(5)),
3232
'lat': (['y'], numpy.arange(5)),
3333
'depth': (['z'], 4.25 - numpy.arange(5), {'positive': 'down'}),

0 commit comments

Comments
 (0)