[Pandas](EN) Add row to DataFrame using pd.concat()


Environment and Prerequisite

  • Python
  • Pandas


Usage

  • Use pd.concat()
import pandas as pd

# create an existing DataFrame
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})

# create a new row as a DataFrame
new_row = pd.DataFrame({'A': [4], 'B': [7]})

# concatenate the existing DataFrame and the new row
df = pd.concat([df, new_row], ignore_index=True)

df


Reference