DataFrame.append() Migration Guide

Why Old Code Fails (Legacy Reference)

Previously, developers used to append rows or dictionaries directly to a DataFrame using the instance method:

# LEGACY CODE (DO NOT USE IN PANDAS 2.0+)
import pandas as pd

df = pd.DataFrame({'Name': ['Ravi'], 'Marks': [85]})
new_row = {'Name': 'Raju', 'Marks': 90}

# This will throw an AttributeError in modern Pandas
# df = df.append(new_row, ignore_index=True)

Error Raised:

AttributeError: 'DataFrame' object has no attribute 'append'

How to Fix It with pd.concat()

To achieve the exact same result in modern Pandas, wrap your dictionary into a single-row DataFrame and pass it to pd.concat():

# MODERN PANDAS 2.0+ EQUIVALENT
import pandas as pd

df = pd.DataFrame({'Name': ['Ravi'], 'Marks': [85]})
new_row_df = pd.DataFrame([{'Name': 'Raju', 'Marks': 90}])

# Use pd.concat instead
df = pd.concat([df, new_row_df], ignore_index=True)
print(df)

Explore Modern Pandas Tutorials




Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer