Adding rows of zeros in pandas

Viewed 1085

In my data, I got 2 columns. row_id, meter_reading.

row_id      meter_reading
1                 20
2                 30
3                 40
4                 50
5                 60

I want to add 10000 rows of zeros below the given table. so, after 5 and 60 it will go like this-

0                  0
0                  0
0                  0
0                  0
....................
....................
2 Answers

Similar to @santiagoNublado's answer, but use df.columns instead when initializing d (not enough rep to comment yet or I would have):

d = pd.DataFrame(0, index=np.arange(10000), columns=df.columns)
df = pd.concat([df,d])

Cheers!

Use:

d = pd.DataFrame(0, index=np.arange(10000), columns=['row_id','meter_reading'])
df = pd.concat([df, d])
Related