I have a pandas.DataFrame
as follows:
df1 =
a b
0 1 2
1 3 4
I\'d like to make this three times to become:
Build a one dimensional indexer to slice both the the values
array and index
. You must take care of the index as well to get your desired results.
np.repeat
on an np.arange
to get the indexerr = np.arange(len(df)).repeat(3)
pd.DataFrame(df.values[r], df.index[r], df.columns)
a b
0 1 2
0 1 2
0 1 2
1 3 4
1 3 4
1 3 4