'DataFrame' object has no attribute 'append' File "D:\chapter12\demo\code\123.py", line 24, in <module> hit_count_7 = hit_count_7.append([{'用户数': time}], ignore_index=True) AttributeError: 'DataFrame' object has no attribute 'append'
时间: 2023-07-28 13:07:02 浏览: 233
pandas dataframe的合并实现(append, merge, concat)
Based on the error message you provided, it seems that you are trying to use the `append()` method on a DataFrame object, but this method does not exist for DataFrames. Instead, you can use the `concat()` method to concatenate DataFrames vertically.
Here's an example of how you can use `concat()` to append a row to a DataFrame:
```
import pandas as pd
# create an empty DataFrame
df = pd.DataFrame(columns=['用户数'])
# append a row to the DataFrame
time = 10
new_row = pd.DataFrame({'用户数': [time]})
df = pd.concat([df, new_row], ignore_index=True)
# print the updated DataFrame
print(df)
```
This should create a new DataFrame with one row containing the value of `time` in the `用户数` column. You can modify this code to fit your specific use case.
阅读全文