How to append rows in a pandas DataFrame using a for loop?
Append rows using a for loop:
import pandas as pd cols = ['Zip'] lst = [] zip = 32100 for a in range(10): lst.append([zip]) zip = zip + 1 df = pd.DataFrame(lst, columns=cols) print(df)
C:\pandas>python example24.py Zip 0 32100 1 32101 2 32102 3 32103 4 32104 5 32105 6 32106 7 32107 8 32108 9 32109 C:\pandas>
2018-11-13T16:48:55+05:30
2018-11-13T16:48:55+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution