DataFrame.append
Adds new row to the end of a DataFrame
danfo.DataFrame.append(values, index, options) [source]
Parameters
Type
Description
Default
Array, Series or DataFrame
Value to append to the DataFrame
The new index value(s) to append to the Series. Must contain the same number of values asnewValues
as they map 1 - 1
.
Optional parameters
inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false
Examples
Appends a new row to the end of a DataFrame
let data = [[0, 2, 4, "b"],
[360, 180, 360, "a"],
[2, 4, 6, "c"]]
let df = new dfd.DataFrame(data)
df.print()
let new_df = df.append([[20, 40, 60, "d"]], [3])
new_df.print()
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║ │ 0 │ 1 │ 2 │ 3 ║
╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 0 │ 0 │ 2 │ 4 │ b ║
╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 1 │ 360 │ 180 │ 360 │ a ║
╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 2 │ 2 │ 4 │ 6 │ c ║
╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║ │ 0 │ 1 │ 2 │ 3 ║
╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 0 │ 0 │ 2 │ 4 │ b ║
╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 1 │ 360 │ 180 │ 360 │ a ║
╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 2 │ 2 │ 4 │ 6 │ c ║
╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 3 │ 20 │ 40 │ 60 │ d ║
╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝