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
Hide 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 @@
},
"column_add"
:
{
}
},
{
"file"
:
"bw100.xlsx"
,
"sheets"
:
[],
"column_mapping"
:
{
},
"column_replace"
:
{
},
"column_add"
:
{
}
}
]
}
plot_comparison.py
View file @
87ab47a0
...
...
@@ -17,37 +17,55 @@ args = parser.parse_args()
def
fill_merged_cells
(
df
,
file_path
,
sheet_name
):
"""填充合并单元格:用前一个非空值向下填充"""
merged_cols
=
set
()
try
:
wb
=
pd
.
ExcelFile
(
file_path
).
book
from
openpyxl
import
load_workbook
wb
=
load_workbook
(
file_path
,
data_only
=
True
)
ws
=
wb
[
sheet_name
]
merged_ranges
=
ws
.
merged_cells
.
ranges
if
not
merged_ranges
:
wb
.
close
()
return
df
for
merged_range
in
merged_ranges
:
min_col
,
min_row
=
merged_range
.
min_col
,
merged_range
.
min_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
)
wb
.
close
()
except
Exception
as
e
:
print
(
f
" 检测合并单元格失败:
{
e
}
"
)
return
df
for
merged_range
in
merged_ranges
:
min_col
,
min_row
=
merged_range
.
min_col
,
merged_range
.
min_row
max_col
,
max_row
=
merged_range
.
max_col
,
merged_range
.
max_row
for
row
in
range
(
min_row
+
1
,
max_row
+
1
):
for
col
in
range
(
min_col
,
max_col
+
1
):
ws
.
cell
(
row
,
col
).
value
=
first_cell
for
col_idx
in
range
(
min_col
,
max_col
+
1
):
merged_cols
.
add
(
col_idx
-
1
)
df
=
pd
.
read_excel
(
file_path
,
sheet_name
=
sheet_name
,
engine
=
'openpyxl'
)
except
Exception
:
pass
wb
.
close
(
wb
)
except
Exception
as
e
:
print
(
f
" 检测合并单元格失败:
{
e
}
"
)
return
df
if
not
merged_cols
:
return
df
for
col
in
df
.
columns
:
df
[
col
]
=
df
[
col
].
fillna
(
method
=
'ffill'
)
if
pd
.
api
.
types
.
is_numeric_dtype
(
df
[
col
]):
col_values
=
df
[
col
].
dropna
()
if
len
(
col_values
)
>
0
and
col_values
.
apply
(
lambda
x
:
float
(
x
).
is_integer
()
if
pd
.
notna
(
x
)
else
True
).
all
():
try
:
df
[
col
]
=
df
[
col
].
astype
(
int
)
except
(
ValueError
,
TypeError
):
pass
for
i
,
col
in
enumerate
(
df
.
columns
):
if
i
in
merged_cols
:
df
[
col
]
=
df
[
col
].
fillna
(
method
=
'ffill'
)
if
pd
.
api
.
types
.
is_numeric_dtype
(
df
[
col
]):
col_values
=
df
[
col
].
dropna
()
if
len
(
col_values
)
>
0
and
col_values
.
apply
(
lambda
x
:
float
(
x
).
is_integer
()
if
pd
.
notna
(
x
)
else
True
).
all
():
try
:
df
[
col
]
=
df
[
col
].
astype
(
int
)
except
(
ValueError
,
TypeError
):
pass
return
df
...
...
@@ -498,7 +516,7 @@ all_metric_cols = normal_metrics + [c['column'] for c in normalize_configs]
print
(
f
"
\n
普通指标:
{
normal_metrics
}
"
)
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
)
}
个图表..."
)
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