-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py: activity timestamp analysis plot
- Loading branch information
1 parent
4c6f258
commit 4ffa2eb
Showing
7 changed files
with
185 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pandas as pd | ||
from rich.table import Table | ||
from beartype.typing import List | ||
from beartype import beartype | ||
|
||
|
||
@beartype | ||
def dataframe_to_rich_table(df: pd.DataFrame, exclude_columns: List[str] = []) -> Table: | ||
table = Table(show_header=True, header_style="bold magenta") | ||
add_index = "index" not in exclude_columns | ||
if add_index: | ||
table.add_column("index") | ||
|
||
for column in df.columns: | ||
if column not in exclude_columns: | ||
table.add_column(column) | ||
|
||
for index, row in df.iterrows(): | ||
row_content = [] | ||
if add_index: | ||
row_content.append(str(index)) | ||
|
||
for col in df.columns: | ||
if col not in exclude_columns: | ||
row_content.append(str(row[col])) | ||
|
||
table.add_row(*row_content) | ||
|
||
return table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from rich.console import Console | ||
|
||
|
||
def render_rich(it) -> str: | ||
console = Console() | ||
with console.capture() as capture: | ||
console.print(it) | ||
|
||
return capture.get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters