@@ -1143,23 +1143,18 @@ def to_dataframe(
11431143 ]
11441144 return pd .concat (df_list , ignore_index = True )
11451145
1146- def print_data_tabular (
1146+ def _prepare_dataframe (
11471147 self ,
1148- file : IO [str ] = sys .stdout ,
11491148 include_units : bool = True ,
11501149 include_delegate_debug_data : bool = False ,
1151- ) -> None :
1150+ ) -> pd . DataFrame :
11521151 """
1153- Displays the underlying EventBlocks in a structured tabular format, with each row representing an Event.
1154-
11551152 Args:
1156- file: Which IO stream to print to. Defaults to stdout.
1157- Not used if this is in an IPython environment such as a Jupyter notebook.
11581153 include_units: Whether headers should include units (default true)
11591154 include_delegate_debug_data: Whether to include delegate debug metadata (default false)
11601155
11611156 Returns:
1162- None
1157+ Returns a pandas DataFrame of the Events in each EventBlock in the inspector, with additional filtering.
11631158 """
11641159 combined_df = self .to_dataframe (include_units , include_delegate_debug_data )
11651160
@@ -1171,7 +1166,44 @@ def print_data_tabular(
11711166 ]
11721167 filtered_column_df .reset_index (drop = True , inplace = True )
11731168
1174- display_or_print_df (filtered_column_df , file )
1169+ return filtered_column_df
1170+
1171+ def print_data_tabular (
1172+ self ,
1173+ file : IO [str ] = sys .stdout ,
1174+ include_units : bool = True ,
1175+ include_delegate_debug_data : bool = False ,
1176+ ) -> None :
1177+ """
1178+ Displays the underlying EventBlocks in a structured tabular format, with each row representing an Event.
1179+
1180+ Args:
1181+ file: Which IO stream to print to. Defaults to stdout.
1182+ Not used if this is in an IPython environment such as a Jupyter notebook.
1183+ include_units: Whether headers should include units (default true)
1184+ include_delegate_debug_data: Whether to include delegate debug metadata (default false)
1185+
1186+ Returns:
1187+ None
1188+ """
1189+ df = self ._prepare_dataframe (include_units , include_delegate_debug_data )
1190+ display_or_print_df (df , file )
1191+
1192+ def save_data_to_tsv (
1193+ self ,
1194+ file : IO [str ],
1195+ ) -> None :
1196+ """
1197+ Stores the underlying EventBlocks in tsv format to facilitate copy-paste into spreadsheets.
1198+
1199+ Args:
1200+ file: Which IO stream to print to. Do not use stdout, as tab separator is not preserved.
1201+
1202+ Returns:
1203+ None
1204+ """
1205+ df = self ._prepare_dataframe ()
1206+ df .to_csv (file , sep = "\t " )
11751207
11761208 # TODO: write unit test
11771209 def find_total_for_module (self , module_name : str ) -> float :
0 commit comments