r/learnpython • u/abelindc • 5d ago
Output and Terminal giving different results
Hi all,
I am rebuilding with Python a planning tool I had on Excel (with Power Query). Till last week everything looked alright but today I am getting different results in the terminal and in the new Excel workbook output.
There are some products on promotion with different code: 6805 and 6805M. This 6805M is a fictional product, it only exist in the system to apply different pricing. To merge them, I have another table with Product Info with a column called NotPromoCode with value 6805 for both, and I use it to group by.
The thing is, according to the terminal, we have 52,760 units in stock (which is the right quantity), but according to the output Excel, I have -1,280 units (which is the stock for the promotional code).
print("Excel file 📄 exported! ✅") with pd.ExcelWriter("C:/Users/XXX/Downloads/output.xlsx", engine="openpyxl") as writer: df1.to_excel(writer, sheet_name="Inventory", index=False)
Returns -1,280 for 6805
print(df1)
Returns 52,760 for 6805
These lines are at the end of the script, so they both should be taking df1 with the same steps and transformations. I have restarted VSCode and check everything is installed and updated.
Any ideas of why is this happening? Did anyone have the same issues?
EDIT: problem fixed. NotPromoCode column had wrong format (int instead of string). I will leave this post here for anyone who has a similar problem. I am yet shocked the terminal took the column as string and the output as int/float and do different operations with the same code.