Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Tuesday, October 30, 2018

Update! (Oct 2018)

Hey there readers! Thanks for your patience with my long delay in posting, life's been crazy but good stuff. I've switched back to working at big4, with a focus on Data Analytics and Accounting, have had 2 kids, and moved back to the DC area. I've been doing a lot with Python, and am very excited to share here what I've been up to!

First off, let me say that this is a really exciting time for any of you who are accounting professionals or accounting students and are interested in Python, data analytics, and/or data visualization. I'm planning to get into some of the cool things happening around all of those, and share my adventures with all.

One notable interesting pursuit I've been working on is with the AICPA's Audit Data Analytics committee. I worked with a working group on the committee to put together some code and a jupyter notebook to pull in a sample trial balance and general ledger, and run some standard journal entry tests on the data. I also recorded a video showing how the notebook works, which should be getting posted to AICPA's site and youtube shortly. The code can be found on github here.

I also presented at an ISACA conference in DC on using Python for improving the IT audit process. Here's the slide deck.

I've been thinking a lot about how to get Python into the hands of non-programmer accountants, and I think one of the easiest ways right now is through Microsoft's Azure platform. It's currently free to run Python code in the cloud, as long as you have a Microsoft account. I can create notebooks in folders available to the public, and you can go and easily clone the folder and start using it on your own.

Try out Python!


Let's try this - if you're reading this and interested in trying Python, go over to Microsoft's Azure website to login and clone their intro library.

Step 1- Go to https://notebooks.azure.com/Microsoft/libraries/samples
Step 2- Click the Clone icon
Step 3- Login to your Microsoft account. Now you should see a page that looks just like the Microsoft page, but now it's in your own personal notebook folder.
Step 4- Click on the "Introduction to Python.ipynb" file to open up the interactive notebook.

Now you should be able to interact with the notebook, being able to edit and run the cells. To run a cell, hold Shift and press Enter on your keyboard.

If this is easy enough to do, then try doing the same thing with my "Accounting and Python Basics.ipynb" file at https://notebooks.azure.com/danshorstein/libraries/python4cpas

Here's a screenshot of the notebook:


Cheers!
-Dan

Friday, December 2, 2016

Getting Started with Python4CPAs: Step 2 - Write a Simple Program!

Hello again, fellow CPAs and accountants, it's time to write some code! If you haven't already done so, download and install the Anaconda Python 3 distribution package.





NOTE: If you are new to programming, definitely start the journey here. If you've done some programming before and know a little Python already, feel free to skip ahead to a later step.




Let's Get Coding!



We will start with a simple Python editor called IDLE that you should now have on your machine.

To start, open Windows run (windows key + r), type in 'idle', then hit enter.


Starting IDLE in Windows


🍎If you're a mac person, open terminal, type 'idle3', then enter.🍎



Here's what your shell should look like. Make sure it says "Python 3.X", and not "Python 2.X"
Python 3.x Shell


From the Python Shell, go to File > New File

This opens up the Editor window of Python IDLE. Now you have two windows open: one for the editor, and one for the shell, where the results of the code will be displayed.

Arrange your editor and shell as shown above so they're easy to work with.




From the editor window, save the file with the name 'program.py' or any name you like.


Hello, World!


Let's get started with the old tried and true "Hello world" program. The traditional version of this program prints the statement "Hello, world" to the screen. But because we are Python4CPAs, we get to have a little fun and I'll add an accounting twist. In writing these seven lines of code, you will learn about:
  • creating and saving a new python file in IDLE
  • accepting a user input() and storing it in a variable
  • performing a math calculation and storing the result in a new variable
  • the print() statement
  • string format() method

In the editor, type the following
(See if you can guess what it does as you type it. )

name = input('What is your name? ')
debit = 5000
credit = 3500
net_balance = debit - credit
print('Hello, {}!'.format(name))
print('Debits are {} and Credits are {}'.format(debit, credit))

print('Net balance is {}. Laterz!'.format(net_balance))

Once you've typed in your code as above (if you're lazy you might have copied/pasted), hit F5 to run the file. It will make you save first, and then it will run in the Shell window. When it prompts you, type in your name!




Did it work?

If you entered the code as shown above, the shell should display something like this:



CONGRATS! You just wrote a program!


Here's a little breakdown on how the program works.


name = input('What is your name? ')

The input() prompts the user to type something in, and by using a variable name and '=', the user's input is saved to the variable called "name"



debit = 5000
credit = 3500 


Here we are assigning the numbers 5000 and 3500 to variables debit and credit. These are called "int" type, or integers, and they do not have decimals. We'll get much heavier into numbers in the next few sessions.



net_balance = debit - credit

Python can do math, hooray! Here we are subtracting the credit variable from the debit variable, and putting the resulting calculation into a variable called "net_balance".



print('Hello, {}!'.format(name))
print('Debits are {} and Credits are {}'.format(debit, credit))
print('Net balance is {}. Laterz!'.format(net_balance))

Here are our three print() statements. Print statements must use parenthesis, and any strings printed must be within quotation marks (Python accepts single or double quotes).

We've gotten a bit fancy here and used a neat feature called the format() method. Format() allows you to insert open/closed brackets within a string as a placeholder, and then you can pass variables through to those placeholders by putting them in the parentheses of format(), separated by commas. If we just wanted to print a simple hello, it would just be print('Hello')

Note how the format method is attached to the string with a period. This is common in programming languages and python as well, and just means we are calling the format method on the string. But you don't worry about all that today. For now, just get it to work, print out the results, and put them up on your fridge.


I encourage you to play around with this program, change the numbers, change the print statements, and just have fun. That's the best way to learn something new.


Great job!


Well, that's it for this one. Next time we'll get more advanced, and before too long we'll get you doing something that actually might be useful in your job, hopefully!

Questions? Suggestions? Please leave me some feedback! 

Also please sign up for the RSS feed, and follow me on twitter - @python4cpas and @dtizzlenizzle

Tuesday, September 6, 2016

Data Analytics, Automation, and the Future of Accounting

It looks like some of the accounting folks out there are starting to realize how important data analytics and automation are to the accounting profession, and it's refreshing to see this! While I think we're still a ways to go before we see any major changes, it's at least a step in the right direction that there are some good articles getting written on the topics. These two articles piqued my interest and thought I would share.

Prospecting the Next Machine Age  - Finding CPAs’ role in the technological future. (Accounting Today)

To me, this article is saying automation is going to play a heavy role in the future of the accounting practice, and we shouldn't fear it. Instead, we should embrace it. I agree, and I think Python can play a huge role in helping provide all accountants with some basic automation tools at no cost, other than the time it takes to learn to use Python.

The next frontier in data analytics  - Why CPAs and organizations need to learn to use advanced technology to predict and achieve outcomes.  (Journal of Accountancy)

This article is a nice overview and discussion on data analytics in accounting and auditing. It mentions IDEA, ACL, and Excel as three tools commonly used in data analytics, but like most other places I've been reading about data analytics in Accounting, it doesn't mention Python. IDEA and ACL are very powerful and useful tools, but not cheap. Most accountants have Excel, but it's very limited. Python provides a nice middle ground that I think will help get a lot of the accounting firms and accounting departments to the next frontier if they don't have access to ACL or IDEA.

The article ends with the line "CPAs, whether working in public practice or industry, will enhance their career opportunities through the acquisition of additional data analytics expertise." Enter Python, the best tool for this job in my opinion.

........................

So what now? Stay tuned! I'm planning my next post as a super basic intro to Python for the non programmer, which will discuss the various ways to access Python, and will provide a few simple programs to try out. Sign up to receive an email notification when I add new posts!