Skip to Content
Numerical Computing with Python
book

Numerical Computing with Python

by Pratap Dangeti, Allen Yu, Claire Chung, Aldrin Yim
December 2018
Beginner to intermediate
682 pages
18h 1m
English
Packt Publishing
Content preview from Numerical Computing with Python

How to do it...

  1. Let's read in stock data for 2016, 2017, and 2018 into a list of DataFrames using a loop instead of three different calls to the read_csv function. Jupyter notebooks currently only allow a single DataFrame to be displayed on one line. However, there is a way to customize the HTML output with help from the IPython library. The user-defined display_frames function accepts a list of DataFrames and outputs them all in a single row:
>>> from IPython.display import display_html>>> years = 2016, 2017, 2018>>> stock_tables = [pd.read_csv('data/stocks_{}.csv'.format(year),                                index_col='Symbol')                     for year in years]>>> def display_frames(frames, num_spaces=0):        t_style = '<table style="display: inline;"' tables_html = [df.to_html().replace('<table', ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Numerical Computing with NumPy

Mastering Numerical Computing with NumPy

Umit Mert Cakmak, Tiago Antao, Mert Cuhadaroglu

Publisher Resources

ISBN: 9781789953633OtherOtherErrata Page