r/Python • u/blademan88 • Aug 07 '14
Python for business analytics reporting
Hi all,
We have a database with a bunch of data we'd like reporting on. The plan is to generate about 40 graphs/day. I'm not here to ask how to format a graph or something like that, but rather I'm trying to understand high level what is the best option for tackling this. I am debating if to use Excel or Python for this. Excel will be easy to make graphs but a little bit harder to automate end to end and will be harder to set up alerts (e.g. if value increase 10% day over day, send an alert). Overall, I'm familiar with Excel options but wanted to understand what the community thought would be the best options for tackling business reporting with Python. Some specific questions:
- What graphing library would I use? I've used matplotlib but I'm wondering if there is a package better suited for creating nice looking relatively simple business charts.
- What can I use to combine and distribute the results? Is there a library that helps me combine everything into a nicely distributed PDF (or some other format)?
- Do you have any additional thoughts/concerns/callouts for trying to achieve this goal?
I'm not determined to use Excel or Python, it just seems like it would be easiest. If someone has a different suggestion, I'd be very open to using it.
I very much appreciate the help.
Edit: Great to see so much feedback. Some additional notes:
- Our data is stored in Redshift, which is a AWS data warehouse based on a heavily modified version of postgres.
- I use Excel for Mac. I've thought many times about switching to PC but our entire company runs on mac, so I'm worried that when I do create Excel programs that others will use, we'll have compatibility issues. I bring this up because I think its a knock for Excel since VBA is not ideal on PC.
- I have access to EC2 and any other AWS service.
51
u/toshitalk Aug 08 '14 edited Aug 08 '14
Asking
pythonvsexcelin the /r/python is like asking about the benefits of having children in /r/childfree. For some balance, I'll talk about excel.Excel automation is very, very, easy to do. You can even use an odbc connector for excel to automatically pull in data on a daily basis. 40 graphs/day, especially if you already have the excel knowledge, may actually be the easier option. Beyond that, think about the technical knowledge at your company-- are the people around you more familiar with python, or excel?
The alerts you mention are very straightforward to do in excel. The reports are just as easy, excel natively supports saving to pdf (you'd do this in vba).
That said, you need to also mention other specifics about your company.
Do you use sharepoint as your 'server' architecture? If so, consider excel.
Do you have linux servers sitting around? Consider python.
The cost of learning python is actually a little steeper than learning vba, but python has greater flexibility. Do you have very limited time resources? Consider excel.
Are you using this as an excuse to learn a programming language? Strongly recommend python.
Lastly, the people in here saying excel is shit don't realize the power of excel. Excel is a very powerful application and can be used to do a great many things, all of which are possible in python. However, the visual environment that excel provides cannot be underestimated-- it may actually be faster to develop a full application in excel than even python.
Also, if you're doing any truly serious business analytics, you shouldn't be using either of these; you should be using Tableau, chartio, pentaho, or another piece of software for business intelligence.
32
u/sentdex pythonprogramming.net Aug 07 '14
Python over Excel any day. Python gives you far more logic, customization, and automation than Excel ever could.
Matplotlib is capable of having nice looking, simple graphs, you just need to customize. The easiest thing to do there is to use styles, and you can even use some pre-made ones so you don't have to bother learning much at all: http://pythonprogramming.net/matplotlib-styles-tutorial/
I'd personally suggest you look into Python, Pandas, and Matplotlib to do the majority of your work. From there, look into one of the many py-PDF modules out there to see if one of those suits your needs.
As for pandas: might I suggest the link I posted in here earlier: http://pythonprogramming.net/python-pandas-data-analysis/
Best wishes! If you have any questions, I'd be happy to further elaborate.
10
u/jmmcd Evolutionary algorithms, music and graphics Aug 08 '14
Re Matplotlib, a lot has happened in this area recently:
http://bokeh.pydata.org/
https://plot.ly/python/
https://github.com/vispy/vispy
9
u/Jetien Aug 08 '14
5
u/toyg Aug 08 '14
When you mentioned Excel and Python, my mind went straight to Resolver One. Unfortunately, Resolver Systems seem to have shut down.
Back to your problem, i think the main difference between Excel and Python is the knowledge gap: Python is still a niche, whereas VBA or C# people are a dime a dozen. The ecosystem for that sort of requirements is much more developed on the Microsoft side, so chances are that Visual Studio or an add-on can already do 90% of what you need; whereas with Python you'll likely have to write everything from scratch -- more fun for you, but more of a headache for the company to maintain if you step under a bus, so to speak. If you go for Python, you'll also have to decide how to store your data (csv files? xml? rdbms?) -- again, more work and complexity.
If you know of some specific python lib or tool that would help you (I remember reading of a python lib that could do OLAP cubes, and I know BoA developed quite a bunch of python-based systems of debatable quality) or you are 100% sure that python will speed up your development times because of feature X or Y, by all means consider it, but to be honest, for something like business reporting, the ecosystem is so much more developed on the Microsoft side, I would struggle to justify my beloved snake.
EDIT: ...or you could use both, via IronPython :)
5
u/LessonStudio Aug 08 '14
I will ask questions before I can really answer:
But I do have a few areas that you could explore. Python is an excellent tool (but what other answer would you expect from this subreddit?) but Python and Excel are not mutually exclusive. It is possible to generate an Excel spreadsheet from Python. Thus you can have the best of both worlds. Or you can have Python massage the data in to an easily digestible format for an excel spreadsheet.
Also if Python is regularly run or is running as a background process then this can separately run your alerts.
But the best way would be guided by my first questions.
8
u/MonkeyDeathCar Aug 08 '14
As much as I hate to be the one to say it, I'd recommend going with Python to generate csvs, and Excel to display the data in graphs.
WAIT HEAR ME OUT
Of course matplotlib is going to be better. But If this guys office is anything like mine, the number of people who "get" that will be close to zero, and will insist on receiving their data in Excel anyway. Especially if you're going to be showing this data to anyone in sales or accounts. Excel might as well be the operating system for half of corporate America, and if they figure out a way to receive email inside of Excel, it may very well happen in the future ("Excel OS" ha ha CRINGE).
VBA is gutter trash, yes, but it's easy to jimmy something together and everybody will think you're a motherfucking wizard for knowing how to use it.
Give Excel a second thought. It's the second technical choice, but it may very well be the first logistical choice in your situation.
4
u/fnl Aug 07 '14
Disclaimer: I love Python, much more than R. But to be honest, I suggest you investigate R. With ggplot and shiny+RMarkdown you can streamline a process to generate those reports as nicely formatted Word files for your boss. Generating great looking plots in R is way simpler than in any other environment I am aware of.
2
u/ruffyen Aug 08 '14
I would look into using Python and Web technology like chartjs depending on your needs. Use Python to produce the data in json format and then use a web front-end
I do this now but we are using sql/. Net but that is just because we are a .Net shop.
How is the original data stored, that has some bearing.
6
u/nbktdis Aug 08 '14
Consider using ipython notebook for data hacking and review.
You can install it easily via Anaconda
2
u/KyleG Aug 07 '14
Excel is shit. Period. It's expensive, slow, difficult to program for, and has all kinds of quirky stuff that does things like cause investment banks to make billion dollar blunders. It persists due to institutional inertia and nothing else.
2
u/[deleted] Aug 08 '14
Does your company have JMP? I started with Excel, got frustrated and then moved to Pandas/Python, now I'm using JMP.
2
u/[deleted] Aug 08 '14
Do I understand correctly that you want to create dashboards? If you are in a corporate environment, how about using Tableau or QlikView?
2
u/beall49 Aug 08 '14
Since you're saying excel I'm going to assume windows environment. I'm wondering what db you're using. If you're using Sql server as your db, I'd recommend using SSRS since it comes with SQL Server for freezies. It's really good for showing off charts or tables of data that your user can filter. Plus it's web based which makes it accessible to all.
When it comes to alerts, I'd also do that on the db side, much easier to do that on trigger than to have some script that monitors (IMO). Plus depending on your db, you can really fine tune your alerts (email, sms, voice, etc.).
1
u/manueslapera Aug 08 '14
if you wanna do simple to use, nice looking plots, id check either seaborn, or ggplot (yhat's port).
You could also try plot.ly, but i wouldnt recommend for a business case (data goes somewhere else).
1
u/shaggorama Aug 08 '14
Several of the core developers of the python data science stack recently started a new company called datapad which is producing a BI solution you might be interested in checking out.
1
u/[deleted] Aug 08 '14
i love python, but let's put it this way. if this isn't your business, go with what you have. if excel is what everyone uses, use excel. you don't want to force everyone to learn a new technology just because you like it.
an example is Daimler, these guys make super cars. business analytics? my friend spent 6 months over there writing VBA scripts. Comp Sci grad.
Comp Sci at its core is effective problem solving. solve your problem in a way that would cost your company the least amount of money while delivering a product they can effectively use.
1
u/newpythonaccount Aug 08 '14 edited Aug 08 '14
I would build these as web applications. So you could use Python on your back end and JavaScript, HTML, CSS for your front end. If your mentioning excel though it sounds like Visual Studios and C# would be a better option.
Or you can use an out of the box solution like Qlik, Tableau, or Spotfire.
1
u/farts_are_adorable Aug 08 '14 edited Nov 02 '17
deleted 0.9439 What is ^^^this?
1
u/TraptInaCommentFctry Aug 08 '14
I agree with others about pandas, matplotlib, ipython for chart-hacking, seaborn for making graphs look nice. But - this is a plan for making static graphs. sure, you can run the script(s) multiple times a day, but you're making a static report. You should consider a tool like Looker, if you have the budget. Looker will connect to your db back end and, with some modeling that will be familiar if you're in the sql world, make charts that update with the click of a button. Also check out Chartio. PM me if you'd like to discuss.
1
u/Coaste Aug 08 '14
Why not both? found this on /r/Python a while ago. Haven't tried it, and don't know what exactly it can do (if it can help you with the graphs), but go ahead and read about it, and it might help. http://xlwings.org/
1
u/toyg Aug 09 '14
Ha, I remembered the OLAP stuff I mentioned: http://cubes.databrewery.org/