Skip to content

DataFrame Append to Concat

Sourcery suggestion id: dataframe-append-to-concat

Available starting with version 1.1.0

Description

Use pandas.concat() instead of the deprecated DataFrame.append().

Before

import pandas as pd

df = pd.DataFrame(
    [["Python", 190], ["JavaScript", 33],],
    columns=["Language", "Number of rules"],
)
other = pd.DataFrame([{"Language": "Java", "Number of rules": 5}])

df.append(other)

After

import pandas as pd

df = pd.DataFrame(
    [["Python", 190], ["JavaScript", 33],],
    columns=["Language", "Number of rules"],
)
other = pd.DataFrame([{"Language": "Java", "Number of rules": 5}])

pd.concat([df, other])

Explanation

pandas.DataFrame.append() has been deprecated.

Use pandas.concat() instead.

See the DataFrame docs