If you’re like many of Excel’s 750 million users, you want to do more with your data—like repeating similar analyses over hundreds of files, or combining data in many files for analysis at one time. This practical guide shows ambitious non-programmers how to automate and scale the processing and analysis of data in different formats—by using Python.
After author Clinton Brownley takes you through Python basics, you’ll be able to write simple scripts for processing data in spreadsheets as well as databases. You’ll also learn how to use several Python modules for parsing files, grouping data, and producing statistics. No programming experience is necessary.
Create and run your own Python scripts by learning basic syntax
Use Python’s csv module to read and parse CSV files
Read multiple Excel worksheets and workbooks with the xlrd module
Perform database operations in MySQL or with the mysqlclient module
Create Python applications to find specific records, group data, and parse text files
Build statistical graphs and plots with matplotlib, pandas, ggplot, and seaborn
Produce summary statistics, and estimate regression and classification models
Schedule your scripts to run automatically in both Windows and Mac environments
Chapter 1Python Basics
How to Create a Python Script
How to Run a Python Script
Useful Tips for Interacting with the Command Line
Python’s Basic Building Blocks
Reading a Text File
Reading Multiple Text Files with glob
Writing to a Text File
Chapter 2Comma-Separated Values (CSV) Files
Base Python Versus pandas
Filter for Specific Rows
Select Specific Columns
Select Contiguous Rows
Add a Header Row
Reading Multiple CSV Files
Concatenate Data from Multiple Files
Sum and Average a Set of Values per File
Chapter 3Excel Files
Introspecting an Excel Workbook
Processing a Single Worksheet
Reading All Worksheets in a Workbook
Reading a Set of Worksheets in an Excel Workbook
Processing Multiple Workbooks
Python’s Built-in sqlite3 Module
Find a Set of Items in a Large Collection of Files
Calculate a Statistic for Any Number of Categories from Data in a CSV File
Calculate Statistics for Any Number of Categories from Data in a Text File
Chapter 6Figures and Plots
Chapter 7Descriptive Statistics and Modeling
Chapter 8Scheduling Scripts to Run Automatically
Task Scheduler (Windows)
The cron Utility (macOS and Unix)
Chapter 9Where to Go from Here
Additional Standard Library Modules and Built-in Functions
Python Package Index (PyPI): Additional Add-in Modules
Clinton Brownley, Ph.D., is a data scientist at Facebook, where he is responsible for a wide variety of data pipelining, statistical modeling, and data visualization projects that inform data-driven decisions about large-scale infrastructure. Clinton is a Past-President of the San Francisco Bay Area Chapter of the American Statistical Association and a Council member for the Section on Practice of the Institute for Operations Research and the Management Sciences. Clinton received degrees from Carnegie Mellon University and American University.
The animal on the cover of Foundations for Analytics with Python is an oleander moth caterpillar (Syntomeida epilais).
Oleander caterpillars are orange with tufts of black hairs; they largely feed on oleander, an evergreen shrub that is the most poisonous commonly grown garden plant. The caterpillar is immune to the plant's poison and by ingesting it, becomes toxic to any bird or mammal that tries to eat it. When the oleander was introduced to Florida by the Spanish in the 17th century, the moth already existed in Florida using a native vine as its host plant, but as oleander became more available, the moth adapted to the new plant as its host to such an extent that it became known as the oleander moth.
The adult oleander moth is spectacular: the body and wings are iridescent blue with small white dots, and the abdomen is bright red at its tip. These moths are active during daylight hours, slow-flying, and imitate the shape of wasps. Female moths perch on oleander foliage and emit an ultrasonic acoustic signal that attracts male moths from great distances. When male and female moths are within a few meters of each other, they begin a courtship duet of acoustic calls that continues until mating occurs two or three hours before dawn. Once mated, female moths oviposit on the undersides of the leaves of oleander plants. Egg masses can contain from 12 to 75 eggs. Once hatched, the larvae gregariously feed on the plant tissue between the major and minor leaf veins until the shoot is a brown skeleton. This defoliation does not kill the plant but it does leave it susceptible to other pests.
Comments about oreilly Foundations for Analytics with Python:
Book provides practical examples, a very good launching pad after basic understanding of python fundamentals. Author went to great length to make book descriptive.. I would have liked to see more exercises.
Bottom Line Yes, I would recommend this to a friend