botsplash
Platform
Why Botsplash?
Reviews
Channels
Web Chat
SMS
Voice and Video Call
Facebook Messenger
Google Business Messages
Features
Integrations
Mobile App
Reporting
Single Sign-On
Security
Support
All Features
Solutions
By Industry
Mortgage
Pharmaceutical
Real Estate
Retail
Automobile Sales
By Company Size
SMB
Enterprise
Pricing
Resources
Resource Center
Blogs
News
Help Center
Knowledge Base
FAQs
About
About Us
Our Team
Careers
Newsletter
Login
Request DemoLogin
Posted on 
August 8, 2018

IPython and Jupyter has so much more…

Over the past few weeks that I’ve spent at botsplash, I’ve been using a lot of IPython, mainly in jupyter lab or notebooks along with terminal interfaces when working with larger programs rather than just scripts.

At first I treated it as a replacement for IDLE, just to make writing python a little faster and easier than writing it in normal notepad like applications. But over time I discovered great IPython features that I now use very frequently. Listed below are IPython and related tools I wish I would have known about earlier.

IPython magic:

IPython comes with what are called magic commands. They’re preceded by one or two ‘%’s. Those with only one are global commands, or only effect the next line while two involve ‘cell magic’.

Autoreload

The commands I find myself using the most are a string of commands that will autoreload changes to a module to the current python session.

%load_ext autoreload
%autoreload 2

There’s other options for usage here, but this allows me to use IPython to easily test modules I’m writing in an ad hoc manner, and without the pain of reloading everything every time I hit ctrl-s.

Timing

Often times I want to time something, early on to see if it’s fast enough to just use and move on, and later on in the process to optimize it.

%time times the next line of code.

%%time times the next cell of code. (And will create a cell if used in command line IPython).

%timeit will run the next line of code several times, reporting to you stats about how long it took to run on average.

%%timeit again the same as the above, but will time an entire cell.

*Note: *You probably don’t want to run the timeit commands with a function that outputs text, creates a new file, or takes a very long time to run, since it may run the statement(s) in question over 500,000 times in some cases. If you still want to time a statement more than once, there are additional parameters in the timeit command that you can use to better control how it runs.

‍

Jupyter Widgets

While in most cases, when testing something or experimenting with different variables in a notebook manually editing the values of the variables is fine, but sometimes something a bit nicer and more intuitive can be useful. Especially if you are using the jupyter dashboard view.

Setting up widgets can even allow you to have them interact with each other, some widget reacting to inputs from another.

An example of a widget found in the seaborn library.

Notebook Extensions:

Jupyter notebook has support for custom notebook extensions, however doesn’t come with too many built in. The unofficial notebook extensions linked above solve this problem, and supply many (almost *too *many) notebook extensions. While I don’t come close to using all of them, some of my favorites include:

  • Autopep8
  • Limit Output
  • Scratchpad
  • Variable Inspector

‍

bqplot

The bqplot library is a useful alternative to the more common alternative of matplotlib when interactivity is a priority, as it expresses itself as an IPython Widget, this allows you to use other notebook widgets to get data or set data, giving you the ability to create more involved data ‘playgrounds’.

‍

Qgrid

While most people who use python for data science and related tasks quickly learn the way the Jupyter Notebook can quickly output rows of your data frame to some cell, sometimes I realized this isn’t quite enough for what I wanted to do.

Often, I’ve found myself looking over my data, viewing rows and rows of data looking for inconsistencies or other interesting values that can’t be detected as easily with basic outlier detection or via statistical measures, and aren’t easily visualized. Tasks such as manually checking model results to see what sort of patterns the model may be learning, etc.

‍

Conclusion:

I hope you’ve found or learned something useful in reading this post! I still have a lot to discover about the jupyter ecosystem, but wanted to write a bit about the things I wish I had known when starting.

Have fun and Happy Coding! If you are someone that has explored jupyter further and have thoughts to share, please leave a note. Thanks in advance, appreciate the help.

‍

For more articles on Live Chat, Automated Bots, SMS Messaging and Conversational Voice solutions, explore our blog.

Want to learn more about botsplash platform? Write to us here.

view All Posts
Featured Posts
Blog
Convert your JSON to Forms in React
Blog
Top 3 reasons every car dealership needs live chat
Blog
How to Re-engage Old Leads
Blog
Digital Communication for the Post-Pandemic World
Blog
Tips for Generating High-Quality Leads on Facebook
News
Intercontinental Capital Group Expands Multi-Channel Messaging with Botsplash Partnership
Newsletter
January 2021 at Botsplash
Blog
SMS Marketing Best Practices
Tagged:
Software Engineering
Data Science
Predictive Analytics
Messaging
Chatbots
Engineering
Subscribe
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Stay Connected

Learn more about Botsplash

take me there!

Botsplash Newsletter

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
More Posts

You Might Also Like

Blog
Convert your JSON to Forms in React
Feb 23, 2021
 by 
Sumit Bajracharya
Blog
Top 3 reasons every car dealership needs live chat
Feb 22, 2021
 by 
Lauren Tooley
Newsletter
February 2021 at Botsplash
Feb 9, 2021
 by 
Lauren Tooley
Blog
How to Re-engage Old Leads
Feb 3, 2021
 by 
Bruce Walker
Blog
Digital Communication for the Post-Pandemic World
Feb 2, 2021
 by 
Lauren Tooley
Blog
Tips for Generating High-Quality Leads on Facebook
Jan 28, 2021
 by 
Lauren Tooley
botsplash

9820 Northcross Center Ct
Suite 187
Huntersville, NC 28078

Platform
Web ChatSMSVideo and Voice CallFacebook MessengerGoogle Business MessagesAll Features
Solutions
MortgageReal EstateAutomobile SalesPharmaceuticalRetail
Resource Center
BlogsKnowledge BaseFAQsDevelopers and API
About
About UsCareersContact UsNewsletter
Copyright © , Rohi LLC. All Rights Reserved.
Privacy PolicyTerms of UseStatus Page