Spaces:
Runtime error
Runtime error
File size: 661 Bytes
e84d35a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
"""Trim df."""
import pandas as pd
# fmt: off
def trim_df(
df1: pd.DataFrame,
len_: int = 4,
) -> pd.DataFrame:
# fmt: on
"""Trim df."""
if len(df1) > 2 * len_:
df_trimmed = pd.concat(
[
df1.iloc[:len_, :],
pd.DataFrame(
[
[
"...",
"...",
]
],
columns=df1.columns,
),
df1.iloc[-len_:, :],
],
ignore_index=1,
)
return df_trimmed
return df1
|