0

I am using Visual Studio with Python to build some automated flows to update some Tableau reporting. In all instances the logic works as follows.

  1. Use SQL to query data from the database.

  2. Tack on additional data from Excel.

  3. Pull out the fields/columns I need using iloc and index references, i.e.

    combineddata4 = combineddata3.iloc[:, [
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
        22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 
        40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 52,  
        21, 36, 37, 38, 39  
        ]
    ] 
    
  4. Add computer data time stamp using loc.

  5. Upload to Tableau server.

In most of my flows, everything is working fine, but in this one particular flow, when I add the following statement to add the date timestamp it returns a warning stating A value is trying to be set on a copy of a slice from a DataFrame and I don't understand why. It works fine for all the other reports, but not this one, and I don't understand why.

Why does this statement yield an error stating A value is trying to be set on a copy of a slice from a DataFrame?

Add current timestamp as Run Date

combineddata4.loc['Run_Date'] = datetime.now()

Expecting to add the date timestamp to the dataframe in Python but receiving a warning stating

A value is trying to be set on a copy of a slice from a DataFrame.
edesz
  • 11,756
  • 22
  • 75
  • 123
Mary
  • 1

0 Answers0