This happens because R2 is a subsection of another dataframe(R1 I guess) 
usually made with a slice or a query. Pandas can't guaranty whether that 
change will be applied to the dataframe because it doesn't know whether it 
is a  view or a copy of the original dataframe. If you don't care if the 
change was made to the original as well you can make a copy or you can 
check the change occurred in the original and ignore the warning, but this 
could lead to difficult to detect bugs that's why they put in the warning.

please see the link in the warning for more information.

*https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
 
<https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy>*


*https://www.dataquest.io/blog/settingwithcopywarning/*

On Tuesday, June 9, 2020 at 9:38:32 AM UTC-6, Bibeesh Y S wrote:
>
> Thanks for replying, I'm able to add new columns with LOC or without LOC. 
> My question is why the below message coming while executing the syntax
>
>
>
> *E:\BIBEESH\PYTHON\NSE\Basan_Version_1.ipy:295: SettingWithCopyWarning:A 
> value is trying to be set on a copy of a slice from a DataFrame.Try using 
> .loc[row_indexer,col_indexer] = value instead*
>
> *See the caveats in the 
> documentation: 
> https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
>  
> <https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy>
>   
> R2["BUY_SELL"]="SELL"*
>
> On Tue, Jun 9, 2020 at 10:06 AM Jim Lareau <[email protected] 
> <javascript:>> wrote:
>
>> Yet again, a simple Google search:
>>
>> pandas dataframe add column
>>
>> yields as one result, the url:
>>
>> Adding new column to existing DataFrame in Pandas - GeeksforGeeks
>>
>> https://www.geeksforgeeks.org/adding-new-column-to-existing-dataframe-in-pandas/
>>
>> Which answers your question.
>>
>> Regards, 
>>
>> Jim
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "spyder" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/spyderlib/0142af4e-b02c-4660-b2a8-4c507bcebeabo%40googlegroups.com
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/spyderlib/7c08b87e-2a78-44a5-81df-edbd5aed56e4o%40googlegroups.com.

Reply via email to