添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If you're getting the error 'DataFrame' object has no attribute 'append' , it's possible that you have a very old version of Pandas installed. In more recent versions of Pandas, append() is no longer used to add rows to a DataFrame.

You can achieve the same result using the concat() method. Here's the corrected code using concat() :

Example :

import pandas as pd
data = {
    'programming': ['python', 'c++', 'java', 'javascript'],
    'topic': ['pandas', 'variable in C', 'interface', 'function'],
    'unit': [101, 102, 103, 104]
# Create a DataFrame
df = pd.DataFrame(data)
# Create a dictionary for the new row
new_row = {'programming': 'ruby', 'topic': 'object-oriented programming', 'unit': 105}
# Append the new row to the DataFrame
df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
print(df)

This code should work regardless of your Pandas version and will append the new row to the DataFrame correctly.

# Instead of using append, use concat in a loop for data_frame in reader . read (): data_frame_list . append ( data_frame ) result_df = pd . concat ( data_frame_list , axis = 0 )