i wrote the below code and converted into dataframe also but getting key error 1
df = (Invoice_No,Date,Lot_No,Expiry_Date,Date_of_Manufacturing,Ethicon_General_PO,Extras)
df = pd.DataFrame(df)
columns = ['INVOICE','DATE','LOT_NO', 'EXPIRY_DATE','DATE_OF_MANUFACTURING','ETHICON_GENERAL_PO','Extras']
df['Name'] = columns
df1 = pd.DataFrame(df)
Alteryx.write(df1,1)
please help to resolve this.
Thanks
Solved! Go to Solution.
Hi,
Not quite sure what you're trying to achieve but you might want to debug your code.
I changed the code to below and it works:
from ayx import Alteryx
import pandas as pd
df = pd.DataFrame()
columns = ['INVOICE','DATE','LOT_NO', 'EXPIRY_DATE','DATE_OF_MANUFACTURING','ETHICON_GENERAL_PO','Extras']
df['Name'] = columns
Alteryx.write(df,1)
i am having another column which is coming from the first line (bold one)
for line in text.split('\n'):
if line.endswith('Diagnostics'):
Invoice_No = line.split()[0]
Date = line.split()[1]
#Invoice = Invoice_re.search(line)
#if Invoice:
# Invoice_No = Invoice.groups(1)
elif line.startswith('Batch'):
Lot_No = line.split()[-1]
elif line.startswith('Expiry'):
Expiry_Date = line.split()[-1]
elif line.startswith('Manufacturing'):
Date_of_Manufacturing = line.split()[-1]
elif line.startswith('Our Ref.'):
Ethicon_General_PO = line.split()[-1]
elif line.startswith('731670'):
Extras = line.split()[0:10]
df = (Invoice_No,Date,Lot_No,Expiry_Date,Date_of_Manufacturing,Ethicon_General_PO,Extras)
df = pd.DataFrame(df)
columns = ['INVOICE','DATE','LOT_NO', 'EXPIRY_DATE','DATE_OF_MANUFACTURING','ETHICON_GENERAL_PO','Extras']
df['Name'] = columns
df1 = pd.DataFrame(df)
df1
Alteryx.write(df1,1)
i am getting this output. but Alteryx.write (df,1) is not working for me.
showing Key error:1
You need to assign a column name for your 1st column.
Something like below:
df = pd.DataFrame()
df['value'] = (Invoice_No,Date,Lot_No,Expiry_Date,Date_of_Manufacturing,Ethicon_General_PO,Extras)
df['Name']= ['INVOICE','DATE','LOT_NO', 'EXPIRY_DATE','DATE_OF_MANUFACTURING','ETHICON_GENERAL_PO','Extras']
Alteryx.write(df1,1)
Thanks a lot!
its working now.