While preparing the MWE I have found a possible solution. Feel free to improve it or post another one.
\documentclass{article}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstableread{
size min max avg med
1 2e-03 3e-03 2.5e-03 2.4e-03
10 2.02e-03 3.02e-03 2.72e-03 2.32e-03
123456789 2.02 123.72e9 2.72e9 2.32e-03
}{\loadedtable}
\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
}
\sisetup{
table-format = 3.2e+3,
round-precision=2,
round-mode=places,
scientific-notation=engineering,
group-digits=integer,
group-separator={,},
exponent-product = \cdot,
}
\pgfplotstabletypeset[
header=true,
string type,
multicolumn names,
columns={size,med,min,avg,max},
assign column name/.code={%
\pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{1}{c}{\multirow{2}{*}{#1}} }%
},
columns/size/.style ={column name={\shortstack{Instance\\Size}}, column type={S[scientific-notation=false,table-format=9]}, int detect},
columns/min/.style ={column name=Minimum, column type=S},
columns/avg/.style ={column name=Average, column type=S},
columns/med/.style ={column name=Median, column type=S},
columns/max/.style ={column name=Maximum, column type=S},
every head row/.style={before row=\toprule, after row=\\\midrule\endhead},
every last row/.style={after row=\bottomrule},
]{\loadedtable}
\end{document}
The important bits are:
- to use
\pgfkeyssetvalue
in assign column name/.code
, and
- the additional
\\
line break in after row
in the every head row
style.

siunitx
errors if you're not using theS
column type?S
. Unfortunately I can not reproduce the error I had. On the positive side, I will post a solution for the original problem in a few :)