@@ -1143,23 +1143,18 @@ def to_dataframe(
1143
1143
]
1144
1144
return pd .concat (df_list , ignore_index = True )
1145
1145
1146
- def print_data_tabular (
1146
+ def _prepare_dataframe (
1147
1147
self ,
1148
- file : IO [str ] = sys .stdout ,
1149
1148
include_units : bool = True ,
1150
1149
include_delegate_debug_data : bool = False ,
1151
- ) -> None :
1150
+ ) -> pd . DataFrame :
1152
1151
"""
1153
- Displays the underlying EventBlocks in a structured tabular format, with each row representing an Event.
1154
-
1155
1152
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.
1158
1153
include_units: Whether headers should include units (default true)
1159
1154
include_delegate_debug_data: Whether to include delegate debug metadata (default false)
1160
1155
1161
1156
Returns:
1162
- None
1157
+ Returns a pandas DataFrame of the Events in each EventBlock in the inspector, with additional filtering.
1163
1158
"""
1164
1159
combined_df = self .to_dataframe (include_units , include_delegate_debug_data )
1165
1160
@@ -1171,7 +1166,44 @@ def print_data_tabular(
1171
1166
]
1172
1167
filtered_column_df .reset_index (drop = True , inplace = True )
1173
1168
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 " )
1175
1207
1176
1208
# TODO: write unit test
1177
1209
def find_total_for_module (self , module_name : str ) -> float :
0 commit comments