Skip to content

Commit 9cd1114

Browse files
author
Stanislav Khrapov
authored
[MNT] Replace deprecated argument squeeze with the method .squeeze("columns") in pd.read_csv (#2693)
Replace deprecated argument `squeeze` with the method `.squeeze("columns")` in `pd.read_csv`. This argument is deprecated since version `1.4.0` of `pandas` (see https://pandas.pydata.org/docs/whatsnew/v1.4.0.html and pandas-dev/pandas#43427).
1 parent ceaf4f8 commit 9cd1114

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

sktime/_contrib/datasets/_single_problem_loaders.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def load_shampoo_sales():
593593
name = "ShampooSales"
594594
fname = name + ".csv"
595595
path = os.path.join(MODULE, DIRNAME, name, fname)
596-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
596+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
597597
y.index = pd.PeriodIndex(y.index, freq="M", name="Period")
598598
y.name = "Number of shampoo sales"
599599
return y
@@ -694,7 +694,7 @@ def load_lynx():
694694
name = "Lynx"
695695
fname = name + ".csv"
696696
path = os.path.join(MODULE, DIRNAME, name, fname)
697-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
697+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
698698
y.index = pd.PeriodIndex(y.index, freq="Y", name="Period")
699699
y.name = "Number of Lynx trappings"
700700
return y
@@ -731,7 +731,7 @@ def load_airline():
731731
name = "Airline"
732732
fname = name + ".csv"
733733
path = os.path.join(MODULE, DIRNAME, name, fname)
734-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
734+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
735735

736736
# make sure time index is properly formatted
737737
y.index = pd.PeriodIndex(y.index, freq="M", name="Period")
@@ -774,7 +774,7 @@ def load_uschange(y_name="Consumption"):
774774
name = "Uschange"
775775
fname = name + ".csv"
776776
path = os.path.join(MODULE, DIRNAME, name, fname)
777-
data = pd.read_csv(path, index_col=0, squeeze=True)
777+
data = pd.read_csv(path, index_col=0).squeeze("columns")
778778

779779
# Sort by Quarter then set simple numeric index
780780
# TODO add support for period/datetime indexing
@@ -823,7 +823,7 @@ def load_gun_point_segmentation():
823823
change_points = np.int32([900])
824824

825825
path = os.path.join(MODULE, DIRNAME, dir, fname)
826-
ts = pd.read_csv(path, index_col=0, header=None, squeeze=True)
826+
ts = pd.read_csv(path, index_col=0, header=None).squeeze("columns")
827827

828828
return ts, period_length, change_points
829829

@@ -861,7 +861,7 @@ def load_electric_devices_segmentation():
861861
change_points = np.int32([1090, 4436, 5712, 7923])
862862

863863
path = os.path.join(MODULE, DIRNAME, dir, fname)
864-
ts = pd.read_csv(path, index_col=0, header=None, squeeze=True)
864+
ts = pd.read_csv(path, index_col=0, header=None).squeeze("columns")
865865

866866
return ts, period_length, change_points
867867

@@ -898,7 +898,7 @@ def load_PBS_dataset():
898898
name = "PBS_dataset"
899899
fname = name + ".csv"
900900
path = os.path.join(MODULE, DIRNAME, name, fname)
901-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
901+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
902902

903903
# make sure time index is properly formatted
904904
y.index = pd.PeriodIndex(y.index, freq="M", name="Period")

sktime/datasets/_single_problem_loaders.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def load_shampoo_sales():
584584
name = "ShampooSales"
585585
fname = name + ".csv"
586586
path = os.path.join(MODULE, DIRNAME, name, fname)
587-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
587+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
588588
y.index = pd.PeriodIndex(y.index, freq="M", name="Period")
589589
y.name = "Number of shampoo sales"
590590
return y
@@ -693,7 +693,7 @@ def load_lynx():
693693
name = "Lynx"
694694
fname = name + ".csv"
695695
path = os.path.join(MODULE, DIRNAME, name, fname)
696-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
696+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
697697
y.index = pd.PeriodIndex(y.index, freq="Y", name="Period")
698698
y.name = "Number of Lynx trappings"
699699
return y
@@ -734,7 +734,7 @@ def load_airline():
734734
name = "Airline"
735735
fname = name + ".csv"
736736
path = os.path.join(MODULE, DIRNAME, name, fname)
737-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
737+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
738738

739739
# make sure time index is properly formatted
740740
y.index = pd.PeriodIndex(y.index, freq="M", name="Period")
@@ -781,7 +781,7 @@ def load_uschange(y_name="Consumption"):
781781
name = "Uschange"
782782
fname = name + ".csv"
783783
path = os.path.join(MODULE, DIRNAME, name, fname)
784-
data = pd.read_csv(path, index_col=0, squeeze=True)
784+
data = pd.read_csv(path, index_col=0).squeeze("columns")
785785

786786
# Sort by Quarter then set simple numeric index
787787
# TODO add support for period/datetime indexing
@@ -832,7 +832,7 @@ def load_gun_point_segmentation():
832832
change_points = np.int32([900])
833833

834834
path = os.path.join(MODULE, DIRNAME, dir, fname)
835-
ts = pd.read_csv(path, index_col=0, header=None, squeeze=True)
835+
ts = pd.read_csv(path, index_col=0, header=None).squeeze("columns")
836836

837837
return ts, period_length, change_points
838838

@@ -872,7 +872,7 @@ def load_electric_devices_segmentation():
872872
change_points = np.int32([1090, 4436, 5712, 7923])
873873

874874
path = os.path.join(MODULE, DIRNAME, dir, fname)
875-
ts = pd.read_csv(path, index_col=0, header=None, squeeze=True)
875+
ts = pd.read_csv(path, index_col=0, header=None).squeeze("columns")
876876

877877
return ts, period_length, change_points
878878

@@ -914,7 +914,7 @@ def load_PBS_dataset():
914914
name = "PBS_dataset"
915915
fname = name + ".csv"
916916
path = os.path.join(MODULE, DIRNAME, name, fname)
917-
y = pd.read_csv(path, index_col=0, squeeze=True, dtype={1: float})
917+
y = pd.read_csv(path, index_col=0, dtype={1: float}).squeeze("columns")
918918

919919
# make sure time index is properly formatted
920920
y.index = pd.PeriodIndex(y.index, freq="M", name="Period")

0 commit comments

Comments
 (0)