I am trying to insert a row of * (any special character would do) after every n rows of my pandas data-frame. One of the SO post says it can be done using the following code:
s = pd.Series(0, df.columns)
f = lambda d: d.append(s, ignore_index=True)
grp = np.arange(len(df)) // 2
df= df.groupby(grp, group_keys=False).apply(f).reset_index(drop=True)
And I am printing my final dataframe using this
print(final.to_string(index=False))
But when I tried the above code I got the below error
ValueError: Grouper and axis must be same length
My data frame has composite numbered rows and 5 columns. Could you please help?
Also I need to get the code converted to console application(.exe)