@@ -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,47 @@ 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
+
1172
+ def print_data_tabular (
1173
+ self ,
1174
+ file : IO [str ] = sys .stdout ,
1175
+ include_units : bool = True ,
1176
+ include_delegate_debug_data : bool = False ,
1177
+ ) -> None :
1178
+ """
1179
+ Displays the underlying EventBlocks in a structured tabular format, with each row representing an Event.
1180
+
1181
+ Args:
1182
+ file: Which IO stream to print to. Defaults to stdout.
1183
+ Not used if this is in an IPython environment such as a Jupyter notebook.
1184
+ include_units: Whether headers should include units (default true)
1185
+ include_delegate_debug_data: Whether to include delegate debug metadata (default false)
1186
+
1187
+ Returns:
1188
+ None
1189
+ """
1190
+ df = self ._prepare_dataframe (include_units , include_delegate_debug_data )
1191
+ display_or_print_df (df , file )
1192
+
1193
+
1194
+ def save_data_to_tsv (
1195
+ self ,
1196
+ file : IO [str ],
1197
+ ) -> None :
1198
+ """
1199
+ Stores the underlying EventBlocks in tsv format to facilitate copy-paste into spreadsheets.
1200
+
1201
+ Args:
1202
+ file: Which IO stream to print to. Do not use stdout, as tab separator is not preserved.
1203
+
1204
+ Returns:
1205
+ None
1206
+ """
1207
+ df = self ._prepare_dataframe ()
1208
+ df .to_csv (file , sep = "\t " )
1209
+
1175
1210
1176
1211
# TODO: write unit test
1177
1212
def find_total_for_module (self , module_name : str ) -> float :
0 commit comments