How can I ad rows in the dataframe. I am getting the syntax for adding columns in the dataframe but not for the rows.
import pandas as pd
name=['First Name','last Name','College Name']
r=pd.DataFrame[columns=name]
Thanks.
(Oct-02-2018, 08:49 PM)arya_starc Wrote: [ -> ]How can I ad rows in the dataframe. I am getting the syntax for adding columns in the dataframe but not for the rows.
You don't -
pandas.DataFrame
is an immutable object - you may change cell(s) content, but not the shape. Create list of either lists or dictionaries or named tuples, and create
DataFrame
in one call
import pandas as pd
name=['First Name','last Name','College Name']
data = [['John', 'Doe', 'Backwaters'], ....]
r=pd.DataFrame(data, columns=name)
You may use
pandas.concat
to combine
DataFrame
s - but this is an inefficient operation.