Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Fill data in dataframe in pandas for loop

import pandas as pd
df = pd.DataFrame()
list = [['Samreena', 'Computer Science', 100],
    ['Asif', 'Maths', 90],
    ['Mirha', 'Chemistry', 60]
]
for student in list:
    temp_df = pd.DataFrame([student], columns=['Student Name', 'Subjects', 'Marks'])
    df = df.append(temp_df, ignore_index=True)
print(df)
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #Fill #data #dataframe #pandas #loop
ADD COMMENT
Topic
Name
6+3 =