We often see the construct df.loc[subscript] = …
to assign to one DataFrame row. Mikhail_Sam posted benchmarks containing, among others, this construct as well as the method using dict and create DataFrame in the end. He found the latter to be the fastest by far. But if we replace the df3.loc[i] = …
(with preallocated DataFrame) in his code with df3.values[i] = …
, the outcome changes significantly, in that that method performs similar to the one using dict. So we should more often take the use of df.values[subscript] = …
into consideration. However note that .values
takes a zero-based subscript, which may be different from the DataFrame.index.