Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas default index remove
#1
Hi everyone I'm trying to put a Put on woocommerce I extracted the product_id from a csv now I should pass it to the put method
documentation:
https: //woocommerce.github.io/woocommerce-rest-api-docs
but I get this error:

{'code': 'rest_no_route', 'message': "No route provides a match between the URL and the requested method.", 'data': {'status': 404}}

I tried to print the result it should be 774 but I see that it also returns the default index of the Dataframe that is:
0 | 774 I have to remove that index, I think that's the problem
my code:

      
from woocommerce import API
import pandas as pd
 
 
 
def update(id):
 
    data = {
        "stock_quantity": "0"
            }
 
    print(wcapi.put("products/"+id, data).json())
 
wcapi = API(
    url="https://---------",
    consumer_key="ck_e985f38b7c-------",
    consumer_secret="cs_e03fab956a2835990e0----------",
    wp_api=True,
    version="wc/v3"
)
 
df1 = pd.read_csv('eurogold.csv', index_col=0)
df1 = df1.drop_duplicates(['codbar'])  # elimina duplicati
df1['codbar'] = df1['codbar'].astype(str)
print(df1)
 
 
df2 = pd.read_csv('woo.csv', index_col=0)
df2 = df2.dropna().reset_index(drop=True)
print(df2)
 
risultato = df2[df2.sku.isin(df1.codbar)].astype(str)
 
 
 
 
 
for index, row in risultato.iterrows():
    update(risultato.product_id)
Reply
#2
in debug mode id should be 744 but instead 0,744

[Image: Cattura.png]
Reply
#3
what a fool I was wrong to iterate

def update(id):
    data = {
        "stock_quantity": "1"
    }

    print(wcapi.put("products/" + id, data).json())

df1 = pd.read_csv('eurogold.csv', index_col=0)
df1 = df1.drop_duplicates(['codbar'])  # elimina duplicati
df1['codbar'] = df1['codbar'].astype(str)
print(df1)

df2 = pd.read_csv('woo.csv', index_col=0)
df2 = df2.dropna().reset_index(drop=True)
print(df2)

risultato = df2[df2.sku.isin(df1.codbar)].astype(str)


for index, row in risultato.iterrows():
    update(row['product_id'])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas dataframe without index tgottsc1 3 2,970 Feb-01-2021, 05:29 PM
Last Post: snippsat
  pandas index not updating please help bntayfur 0 535 Jun-07-2020, 10:57 PM
Last Post: bntayfur
  Remove \n from list of values within a pandas columns klllmmm 2 6,706 Jun-24-2019, 05:16 AM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020