This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
We've recently made an accessibility improvement to the community and therefore posts without any content are no longer allowed. Please use the spoiler feature or add a short message in the message body in order to submit your weekly challenge.
We are currently experiencing an issue with Email verification at this time and working towards a solution. Should you encounter this issue, please click on the "Send Verification Button" a second time and the request should go through. If the issue still persists for you, please email firstname.lastname@example.org for assistance.
from ayx import Package
from ayx import Alteryx
import pandas as pd
data = Alteryx.read("#1")
a = int(data['Field1'].iloc)
b = int(data['Field2'].iloc)
df = pd.DataFrame(divmod(a,b)).T
df.columns = ['answer','remainder']
result = pd.concat([data,df], axis=1,join='inner')
I started going down a different route but I ended up with so many if statements it was getting too confusing so I started over after a peak at the linked post. Who would've thought I'd prefer long division on paper?
With a little more work, I could convert this to an iterative macro to make it dynamic for larger numbers. It could split the incoming number into segments iteratively after every 15 characters instead of statically after the first 15 characters. It took me long enough to get the right answer that it felt like a win even without including a macro 😂