Pandas Dataframe add rows on top of dataframe

Posted by yash.trojan.25 on Stack Overflow See other posts from Stack Overflow or by yash.trojan.25
Published on 2014-08-24T22:16:07Z Indexed on 2014/08/24 22:20 UTC
Read the original article Hit count: 358

Filed under:
|
|

I am trying to add blank rows on top of the pandas Dataframe data. Basically, some blank rows and some calculation for each row which contains calculations for Average etc. for that column. Can someone please help me how I can do this?

From:

    A   B       D   E   F   G   H   I   J
0   -8  10      532 533 533 532 534 532 532
1   -8  12      520 521 523 523 521 521 521
2   -8  14      520 523 522 523 522 521 522
3   -4  2       526 527 527 528 528 527 529
4   -4  4       516 518 517 519 518 516 518
5   -4  6       528 529 530 531 530 528 530
6   -4  8       518 521 521 521 522 519 521
7   -4  10      524 525 525 525 525 524 524
8   -4  12      522 523 524 525 525 522 523
9   -2  2       525 526 527 527 527 525 527
10  -2  4       518 519 519 521 520 519 520
11  -2  6       520 522 522 522 522 520 523
12  -2  8       551 551 552 552 552 550 552
13  -2  10      533 534 535 536 535 534 535
14  -2  12      537 539 539 539 538 537 539
15  -2  14      528 530 530 531 530 529 530
16  -1  2       518 519 519 521 520 518 520

To:

A   B       D   E   F   G   H   I   J

            Average 525.6   527.1   527.4   528.0   527.6   526.0   527.4
            Sigma   8.6 8.3 8.5 8.1 8.3 8.3 8.4
            Minimum 516 518 517 519 518 516 518
            Maximum 551 551 552 552 552 550 552




0   -8  10      532 533 533 532 534 532 532
1   -8  12      520 521 523 523 521 521 521
2   -8  14      520 523 522 523 522 521 522
3   -4  2       526 527 527 528 528 527 529
4   -4  4       516 518 517 519 518 516 518
5   -4  6       528 529 530 531 530 528 530
6   -4  8       518 521 521 521 522 519 521
7   -4  10      524 525 525 525 525 524 524
8   -4  12      522 523 524 525 525 522 523
9   -2  2       525 526 527 527 527 525 527
10  -2  4       518 519 519 521 520 519 520
11  -2  6       520 522 522 522 522 520 523
12  -2  8       551 551 552 552 552 550 552
13  -2  10      533 534 535 536 535 534 535
14  -2  12      537 539 539 539 538 537 539
15  -2  14      528 530 530 531 530 529 530
16  -1  2       518 519 519 521 520 518 520

© Stack Overflow or respective owner

Related posts about pandas

Related posts about add