Skip to content

Commit dc3c69e

Browse files
committed
Extend compatibility with plotting input data
1 parent afcae9d commit dc3c69e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

trnpy/misc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def df_to_excel(df, path, sheet_names=[], styles=[], merge_cells=False,
195195

196196
kwargs['freeze_panes'] = (freeze_rows, len(df.index.names))
197197
elif kwargs['freeze_panes'] is False:
198-
del(kwargs['freeze_panes'])
198+
del kwargs['freeze_panes']
199199

200200
# Save one DataFrame to one Excel file
201201
df.to_excel(path, merge_cells=merge_cells, **kwargs)
@@ -935,7 +935,10 @@ def create_bokeh_timelines(df, sync_xaxis=True, group_lvl=None,
935935
if group is None:
936936
df_group = df
937937
else:
938-
df_group = df.xs(group, level=group_lvl, axis='columns')
938+
if isinstance(df.columns, pd.MultiIndex):
939+
df_group = df.xs(group, level=group_lvl, axis='columns')
940+
else:
941+
df_group = df[[group]]
939942

940943
for unit in units:
941944
if unit is None:
@@ -1026,7 +1029,7 @@ def create_bokeh_timeline(df, fig_link=None, y_label=None, title=None,
10261029
lines = []
10271030
for y_col, color in zip(y_cols, palette):
10281031
try:
1029-
if not df[y_col].isna().all():
1032+
if not df[y_col].isna().all(axis=None):
10301033
if isinstance(y_col, tuple): # if columns have MultiIndex
10311034
y_col = "_" . join(y_col) # join to match 'source' object
10321035
if kind == 'line':
@@ -1044,7 +1047,7 @@ def create_bokeh_timeline(df, fig_link=None, y_label=None, title=None,
10441047
logger.error('Error with column "%s"', y_col)
10451048
raise
10461049

1047-
if all([df[y_col].isna().all() for y_col in y_cols]):
1050+
if all([df[y_col].isna().all(axis=None) for y_col in y_cols]):
10481051
return column([p], sizing_mode=sizing_mode)
10491052
else:
10501053
custom_bokeh_settings(p) # Set additional features of the plot

0 commit comments

Comments
 (0)