Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tsoc
DataAnalysis
Commits
87ab47a0
Commit
87ab47a0
authored
Mar 18, 2026
by
yanke
Browse files
fix bug
parent
b104ec49
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
18 deletions
+46
-18
bw100.json
bw100.json
+10
-0
plot_comparison.py
plot_comparison.py
+36
-18
No files found.
bw100.json
View file @
87ab47a0
...
@@ -18,6 +18,16 @@
...
@@ -18,6 +18,16 @@
},
},
"column_add"
:
{
"column_add"
:
{
}
}
},
{
"file"
:
"bw100.xlsx"
,
"sheets"
:
[],
"column_mapping"
:
{
},
"column_replace"
:
{
},
"column_add"
:
{
}
}
}
]
]
}
}
plot_comparison.py
View file @
87ab47a0
...
@@ -17,29 +17,47 @@ args = parser.parse_args()
...
@@ -17,29 +17,47 @@ args = parser.parse_args()
def
fill_merged_cells
(
df
,
file_path
,
sheet_name
):
def
fill_merged_cells
(
df
,
file_path
,
sheet_name
):
"""填充合并单元格:用前一个非空值向下填充"""
"""填充合并单元格:用前一个非空值向下填充"""
merged_cols
=
set
()
try
:
try
:
wb
=
pd
.
ExcelFile
(
file_path
).
book
from
openpyxl
import
load_workbook
wb
=
load_workbook
(
file_path
,
data_only
=
True
)
ws
=
wb
[
sheet_name
]
ws
=
wb
[
sheet_name
]
merged_ranges
=
ws
.
merged_cells
.
ranges
merged_ranges
=
ws
.
merged_cells
.
ranges
if
not
merged_ranges
:
if
not
merged_ranges
:
wb
.
close
()
return
df
return
df
for
merged_range
in
merged_ranges
:
for
merged_range
in
merged_ranges
:
min_col
,
min_row
=
merged_range
.
min_col
,
merged_range
.
min_row
min_col
,
min_row
=
merged_range
.
min_col
,
merged_range
.
min_row
max_col
,
max_row
=
merged_range
.
max_col
,
merged_range
.
max_row
max_col
,
max_row
=
merged_range
.
max_col
,
merged_range
.
max_row
first_cell
=
ws
.
cell
(
min_row
,
min_col
).
value
for
col_idx
in
range
(
min_col
,
max_col
+
1
):
merged_cols
.
add
(
col_idx
-
1
)
for
row
in
range
(
min_row
+
1
,
max_row
+
1
):
wb
.
close
()
for
col
in
range
(
min_col
,
max_col
+
1
):
except
Exception
as
e
:
ws
.
cell
(
row
,
col
).
value
=
first_cell
print
(
f
" 检测合并单元格失败:
{
e
}
"
)
return
df
df
=
pd
.
read_excel
(
file_path
,
sheet_name
=
sheet_name
,
engine
=
'openpyxl'
)
for
merged_range
in
merged_ranges
:
except
Exception
:
min_col
,
min_row
=
merged_range
.
min_col
,
merged_range
.
min_row
pass
max_col
,
max_row
=
merged_range
.
max_col
,
merged_range
.
max_row
for
col_idx
in
range
(
min_col
,
max_col
+
1
):
merged_cols
.
add
(
col_idx
-
1
)
wb
.
close
(
wb
)
except
Exception
as
e
:
print
(
f
" 检测合并单元格失败:
{
e
}
"
)
return
df
if
not
merged_cols
:
return
df
for
col
in
df
.
columns
:
for
i
,
col
in
enumerate
(
df
.
columns
):
if
i
in
merged_cols
:
df
[
col
]
=
df
[
col
].
fillna
(
method
=
'ffill'
)
df
[
col
]
=
df
[
col
].
fillna
(
method
=
'ffill'
)
if
pd
.
api
.
types
.
is_numeric_dtype
(
df
[
col
]):
if
pd
.
api
.
types
.
is_numeric_dtype
(
df
[
col
]):
col_values
=
df
[
col
].
dropna
()
col_values
=
df
[
col
].
dropna
()
...
@@ -498,7 +516,7 @@ all_metric_cols = normal_metrics + [c['column'] for c in normalize_configs]
...
@@ -498,7 +516,7 @@ all_metric_cols = normal_metrics + [c['column'] for c in normalize_configs]
print
(
f
"
\n
普通指标:
{
normal_metrics
}
"
)
print
(
f
"
\n
普通指标:
{
normal_metrics
}
"
)
print
(
f
"归一化配置:
{
normalize_configs
}
"
)
print
(
f
"归一化配置:
{
normalize_configs
}
"
)
dist_combinations
=
df_renamed
.
groupby
(
dist_cols
).
size
().
reset_index
()
dist_combinations
=
df_renamed
.
groupby
(
dist_cols
).
size
().
reset_index
(
name
=
'count'
)
print
(
f
"
\n
将生成
{
len
(
dist_combinations
)
}
个图表..."
)
print
(
f
"
\n
将生成
{
len
(
dist_combinations
)
}
个图表..."
)
chart_count
=
0
chart_count
=
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment