Replies: 3 comments
-
To avoid modifying the original DataFrame when using PandasAI, you can create a copy of the DataFrame before performing any operations. This ensures that the original data remains unchanged. Here's how you can modify the code to work with a copy: # Create a copy of the original DataFrame
df_copy = df.copy()
# Convert the 'date' column to datetime format and set it as the index
df_copy['date'] = pd.to_datetime(df_copy['date'])
df_copy.set_index('date', inplace=True)
# Sort the DataFrame by date
df_copy.sort_index(inplace=True)
# Drop any rows with missing values
df_copy = df_copy.dropna()
# Extract the 'close' prices for analysis
close_prices = df_copy['close'] By using To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
but the code generated by agent , not me |
Beta Was this translation helpful? Give feedback.
-
@XJTU-JP can you share more details about the context in which the agent generates this code? |
Beta Was this translation helpful? Give feedback.
-
System Info
pandasai 2.4.0
🐛 Describe the bug
This is the data that is input to the agent
then the agent run this code:
The original data is modified.
How to avoid this problem
Beta Was this translation helpful? Give feedback.
All reactions