First implementation:
\documentclass{article}
\usepackage{array,booktabs}
\usepackage{xparse}
\newcommand{\myhrule}{\rule{1cm}{0.4pt}}
\ExplSyntaxOn
\NewDocumentCommand{\makeruledtabular}{mm}
{% #1 = number of rows, #2 = header
\begin{tabular}{r w{c}{2cm} w{c}{2cm} @{}}
\toprule
#2 \\
\midrule
\int_step_function:nN {#1} \__hafid_ruledtabular_line:n
\bottomrule
\end{tabular}
}
\cs_new_protected:Nn \__hafid_ruledtabular_line:n
{
#1 & \myhrule & \myhrule \\
}
\ExplSyntaxOff
\begin{document}
\makeruledtabular{10}{\multicolumn{1}{c}{\(i\)} & \(P\) & \(y_{m}\) }
\end{document}

More general implementation: the number of columns is determined from the header.
\documentclass{article}
\usepackage{array,booktabs}
\usepackage{xparse}
\newcommand{\myhrule}{\rule{1cm}{0.4pt}}
\ExplSyntaxOn
\NewDocumentCommand{\makeruledtabular}{mm}
{% #1 = number of rows, #2 = header
\hafid_ruledtabular:nn { #1 } { #2 }
}
\seq_new:N \l__hafid_ruledtabular_header_seq
\tl_new:N \l__hafid_ruledtabular_first_tl
\cs_new_protected:Nn \hafid_ruledtabular:nn
{
% absorb the header as a sequence
\seq_set_split:Nnn \l__hafid_ruledtabular_header_seq { & } { #2 }
% split off the first item, which should be centered
\seq_pop_left:NN \l__hafid_ruledtabular_header_seq \l__hafid_ruledtabular_first_tl
% Define the auxiliary function based on the number of items in the header
% At the end, if the header is 'A & B & C & D`, the function will be
% defined to do '#1 & \myhrule & \myhrule & \myhrule \\', where #1 stands
% for the current index in the loop
\cs_set_protected:Nx \__hafid_ruledtabular_line:n
{
##1
\prg_replicate:nn { \seq_count:N \l__hafid_ruledtabular_header_seq }
{ & \exp_not:N \myhrule }
\exp_not:N \\
}
\begin{tabular}
{
r
*{ \seq_count:N \l__hafid_ruledtabular_header_seq } { w{c}{2cm} }
@{}
}
\toprule
\multicolumn{1}{c}{\tl_use:N \l__hafid_ruledtabular_first_tl} &
\seq_use:Nn \l__hafid_ruledtabular_header_seq { & } \\
\midrule
\int_step_function:nN {#1} \__hafid_ruledtabular_line:n
\bottomrule
\end{tabular}
}
\ExplSyntaxOff
\begin{document}
\makeruledtabular{10}{\(i\) & \(P\) & \(y_{m}\) }
\bigskip
\makeruledtabular{15}{A & B & C & D}
\end{document}

The idea is that loop of the form ..._function:...
will deliver the whole loop before anything else is processed, so in the case of a three column table with three rows we will get
\__hafid_ruledtabular_line:n { 1 }
\__hafid_ruledtabular_line:n { 2 }
\__hafid_ruledtabular_line:n { 3 }
and only after this TeX will start to process the first item, therefore getting
1 & \myhrule & \myhrule \\
2 & \myhrule & \myhrule \\
3 & \myhrule & \myhrule \\
yielding the full table body.