Skip to content

Commit 8c4fed5

Browse files
authored
remove deprecated columns arg from to_dataframe and arrow_to_dataframe (#59)
1 parent 9b7fb1e commit 8c4fed5

File tree

2 files changed

+10
-40
lines changed

2 files changed

+10
-40
lines changed

btrdb/transformers.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,13 @@ def arrow_to_series(streamset, agg="mean", name_callable=None):
138138
return [arrow_df[col] for col in arrow_df]
139139

140140

141-
def arrow_to_dataframe(
142-
streamset, columns=None, agg=None, name_callable=None
143-
) -> pd.DataFrame:
141+
def arrow_to_dataframe(streamset, agg=None, name_callable=None) -> pd.DataFrame:
144142
"""
145143
Returns a Pandas DataFrame object indexed by time and using the values of a
146144
stream for each column.
147145
148146
Parameters
149147
----------
150-
columns: sequence
151-
column names to use for DataFrame. Deprecated and not compatible with name_callable.
152-
153148
agg : List[str], default: ["mean"]
154149
Specify the StatPoint fields (e.g. aggregating function) to create the dataframe
155150
from. Must be one or more of "min", "mean", "max", "count", "stddev", or "all". This
@@ -175,13 +170,6 @@ def arrow_to_dataframe(
175170
raise ImportError(
176171
f"Please install Pandas and pyarrow to use this transformation function. ErrorMessage: {err}"
177172
)
178-
# deprecation warning added in v5.8
179-
if columns:
180-
warn(
181-
"the columns argument is deprecated and will be removed in a future release",
182-
DeprecationWarning,
183-
stacklevel=2,
184-
)
185173

186174
if agg is None:
187175
agg = ["mean"]
@@ -227,16 +215,13 @@ def arrow_to_dataframe(
227215
return tmp.to_pandas(date_as_object=False, types_mapper=pd.ArrowDtype)
228216

229217

230-
def to_dataframe(streamset, columns=None, agg="mean", name_callable=None):
218+
def to_dataframe(streamset, agg="mean", name_callable=None):
231219
"""
232220
Returns a Pandas DataFrame object indexed by time and using the values of a
233221
stream for each column.
234222
235223
Parameters
236224
----------
237-
columns: sequence
238-
column names to use for DataFrame. Deprecated and not compatible with name_callable.
239-
240225
agg : str, default: "mean"
241226
Specify the StatPoint field (e.g. aggregating function) to create the Series
242227
from. Must be one of "min", "mean", "max", "count", "stddev", or "all". This
@@ -253,14 +238,6 @@ def to_dataframe(streamset, columns=None, agg="mean", name_callable=None):
253238
except ImportError:
254239
raise ImportError("Please install Pandas to use this transformation function.")
255240

256-
# deprecation warning added in v5.8
257-
if columns:
258-
warn(
259-
"the columns argument is deprecated and will be removed in a future release",
260-
DeprecationWarning,
261-
stacklevel=2,
262-
)
263-
264241
# TODO: allow this at some future point
265242
if agg == "all" and name_callable is not None:
266243
raise AttributeError(
@@ -288,7 +265,7 @@ def to_dataframe(streamset, columns=None, agg="mean", name_callable=None):
288265
]
289266
df.columns = pd.MultiIndex.from_tuples(stream_names)
290267
else:
291-
df.columns = columns if columns else _stream_names(streamset, name_callable)
268+
df.columns = _stream_names(streamset, name_callable)
292269

293270
return df
294271

tests/btrdb/test_transformers.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def test_to_series(self, streamset):
601601

602602
def test_to_series_name_lambda(self, streamset):
603603
"""
604-
assert to_dateframe uses name lambda
604+
assert to_series uses name lambda
605605
"""
606606
result = streamset.to_series(name_callable=lambda s: s.name)
607607
assert [s.name for s in result] == ["stream0", "stream1", "stream2", "stream3"]
@@ -691,23 +691,16 @@ def test_to_dataframe(self, streamset):
691691
df.set_index("time", inplace=True)
692692
assert to_dataframe(streamset).equals(df)
693693

694-
def test_to_dataframe_column_issues_warning(self, statpoint_streamset):
694+
def test_to_dataframe_column_issues_error(self, statpoint_streamset):
695695
"""
696-
assert to_dateframe with column argument issues warning
696+
assert to_dateframe with column argument issues error
697697
"""
698698
columns = ["test/cats", "test/dogs", "test/horses", "test/fishes"]
699-
with pytest.deprecated_call():
699+
with pytest.raises(TypeError) as unexpected_key_err:
700700
statpoint_streamset.to_dataframe(columns=columns)
701-
702-
def test_to_dataframe_column(self, statpoint_streamset):
703-
"""
704-
assert to_dateframe with column argument actually renames columns
705-
"""
706-
columns = ["test/cats", "test/dogs", "test/horses", "test/fishes"]
707-
with pytest.deprecated_call():
708-
df = statpoint_streamset.to_dataframe(columns=columns)
709-
710-
assert df.columns.tolist() == columns
701+
assert "got an unexpected keyword argument 'columns'" in str(
702+
unexpected_key_err.value
703+
)
711704

712705
def test_to_dataframe_multindex(self, statpoint_streamset):
713706
"""

0 commit comments

Comments
 (0)