Reputation: 317
The data may look like this
0 1 2
0 0 0 0
1 1 5 6
2 2 7 4
list=[1.2,1.3,1.4]
How may I insert to it to a dataframe?
0 1 2
0 1.1 1.2 1.3
1 1 5 6
2 2 7 4
I only use a loop to do it.
Is there any function do it?
Upvotes: 1
Views: 44
Reputation: 42886
Use .loc
to select the first row, then insert your list:
mylist = [1.2,1.3,1.4]
df.loc[0] = mylist
Output
0 1 2
0 1.2 1.3 1.4
1 1.0 5.0 6.0
2 2.0 7.0 4.0
Upvotes: 3