cut_dataframe_after_max
- trashpanda.cut_dataframe_after_max(frame_to_cut: pandas.core.frame.DataFrame, condition_column: Optional[Union[str, int]] = None) pandas.core.frame.DataFrame
Cuts a DataFrame after the maximum value of its condition column. If the DataFrame contains only 1 column, then this column is the condition column.
Warning
This method is being replaced by :func:trashpanda.cut_after_max in the next release.
- Parameters
frame_to_cut (DataFrame) – Source frame to be cut at the cutting index.
condition_column (Union[str, int]) – Column or its integer position, which contains the conditional maximum value.
- Returns
DataFrame
Examples
>>> from pandas import DataFrame, Index >>> import numpy as np >>> from doctestprinter import doctest_print >>> v1, v2 = np.arange(0.0, np.pi, np.pi/4.0), np.arange(4) >>> test_data = np.stack((np.sin(v1), v2), axis=1) >>> test_frame = DataFrame( ... data=test_data, ... columns=["b", "a"], ... index=Index(numpy.arange(0.0, 0.4, 0.1), name="x") ... ) >>> doctest_print(test_frame) b a x 0.0 0.000000 0.0 0.1 0.707107 1.0 0.2 1.000000 2.0 0.3 0.707107 3.0 >>> doctest_print(cut_dataframe_after_max(test_frame, "b")) b a x 0.0 0.000000 0.0 0.1 0.707107 1.0 0.2 1.000000 2.0 >>> doctest_print(cut_dataframe_after_max(test_frame, 0)) b a x 0.0 0.000000 0.0 0.1 0.707107 1.0 0.2 1.000000 2.0