Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When try to filter data and make some change as per requirement even afte make new Df from pandas

C:\Users\Vishal Sharma\Desktop\Python\2B\F 2B.py:946: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
test.rename(columns = {a:"Last " +a},inplace = True)
C:\Users\Vishal Sharma\Desktop\Python\2B\F 2B.py:946: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

# Code Start with
# Filter down complete data of overvall recon
test = Final_Recon_read[Final_Recon_read['Remark']== 'Matched']

for a in  test.columns.difference((['GSTIN of supplier', 'Trade/Legal name', 'Invoice number','Invoice Date', 'Supply Attract Reverse Charge'
    , 'Place of supply',  'Source','Purchase Voucher no', 'Voucher Type'])):
    test.rename(columns = {a:"Last " +a},inplace = True)
    

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are trying to assign the value of a filtered data frame to another variable and although pandas will generally allow it, it will raise an error.

Assign a copy of the data frame instead using .copy()

test = Final_Recon_read[Final_Recon_read['Remark']== 'Matched'].copy()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading