Introduction to Python Programming for Business and Social Science Applications

Frederick Kaefer - Loyola University Chicago, USA
Paul Kaefer - Carrot Health
Introduction to Python Programming for Business and Social Science Applications
August 2020 | 392 pages | Sage US
Create Flyer

If you’re in the Americas, please visit our Sage College Publishing website to purchase or sample this book:

Go to College Publishing Website

Description

Would you like to gather big datasets, analyze them, and visualize the results, all in one program? If this describes you, then Introduction to Python Programming for Business and Social Science Applications is the book for you. Authors Frederick Kaefer and Paul Kaefer walk you through each step of the Python package installation and analysis process, with frequent exercises throughout so you can immediately try out the functions you’ve learned. Written in straightforward language for those with no programming background, this book will teach you how to use Python for your research and data analysis. Instead of teaching you the principles and practices of programming as a whole, this application-oriented text focuses on only what you need to know to research and answer social science questions. The text features two types of examples, one set from the General Social Survey and one set from a large taxi trip dataset from a major metropolitan area, to help readers understand the possibilities of working with Python. Chapters on installing and working within a programming environment, basic skills, and necessary commands will get you up and running quickly, while chapters on programming logic, data input and output, and data frames help you establish the basic framework for conducting analyses. Further chapters on web scraping, statistical analysis, machine learning, and data visualization help you apply your skills to your research. More advanced information on developing graphical user interfaces (GUIs) help you create functional data products using Python to inform general users of data who don’t work within Python.


 First there was IBM® SPSS®, then there was R, and now there's Python. Statistical software is getting more aggressive - let authors Frederick Kaefer and Paul Kaefer help you tame it with Introduction to Python Programming for Business and Social Science Applications.



Contents

Preface

Preface

Figures and Tables in the Text Related to the GSS Data Set

Figures and Tables in the Text Related to the GSS Data Set

Figures and Tables in the Text Related to the Taxi Trips Data Set

Figures and Tables in the Text Related to the Taxi Trips Data Set

Python Modules and Packages

Python Modules and Packages

Acknowledgments

Acknowledgments

About the Authors

  • Chapter 1 • Introduction to Python
  • Learning Objectives
  • Introduction
  • Brief Introduction to Python and Programming
  • Setting Up a Python Development Environment
  • Executing Python Code in the IDLE Shell Window
  • Executing Python Code in Files
  • Package Managers
  • Data Sets Used Throughout the Book
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 2 • Building Blocks of Programming
  • Learning Objectives
  • Introduction
  • Good Programming Practice
  • Basic Elements of Python Code
  • Python Code Statements
  • Errors
  • Functions
  • Using Modules of Python Code
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 3 • Further Foundations of Python Programming
  • Learning Objectives
  • Introduction
  • Compound Data Types
  • Lists
  • String Objects
  • Sequence Operations
  • Tuples
  • Dictionaries
  • Example Using Tuples and Dictionaries
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 4 • Control Logic and Loops
  • Learning Objectives
  • Introduction
  • Conditions
  • Conditional Logic
  • Loops
  • Error Handling
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 5 • Reading and Writing to Files Using Python
  • Learning Objectives
  • Introduction
  • Data Input/Output: Using files
  • CSV Files
  • Exporting Our Results
  • Working With Database Files
  • Developing an Interactive Application Using a Database
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • Discussion Questions
  • References
  • Chapter 6 • Preparing and Working With Data Using Pandas
  • Learning Objectives
  • Introduction
  • NumPy
  • Pandas Data Structures
  • Creating Dummy Variables
  • Chapter Summary
  • Glossary
  • Discussion Questions
  • End of Chapter Exercises
  • References
  • Chapter 7 • Obtaining Data From the Web Using Python
  • Learning Objectives
  • Introduction
  • HTML: The Language of the Web
  • Using Python to Read From HTML Files
  • Obtaining GSS Data From the Web: A More Complicated Process
  • Ethical Issues: Inappropriate Use of Web Resources
  • Beautiful Soup
  • JSON: Obtaining Well-Structured Data
  • REST API Queries: A Standardized Way to Access Well-Structured Data
  • Chapter Summary
  • Glossary
  • Discussion Questions
  • End of Chapter Exercises
  • References
  • Chapter 8 • Statistical Calculations Using Python
  • Learning Objectives
  • Introduction
  • Ethical Issues: Considerations When Working With Statistics and Building Models
  • Basic Statistics
  • Using Statistical Modules
  • Pandas Features
  • SciPy Stats Module
  • Statsmodels Module for Multiple Regression
  • Statsmodels Module for Logistic Regression
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 9 • Data Visualization Using Python
  • Learning Objectives
  • Introduction
  • Data Visualization
  • Matplotlib: A Python Library to Visualize Your Data
  • Customizing Matplotlib Plots
  • Creating 3D Plots
  • Using Seaborn Package for Statistical Data Visualization
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 10 • Machine Learning and Text Mining
  • Learning Objectives
  • Introduction
  • Machine Learning
  • Supervised Learning
  • Unsupervised Learning
  • Using Python for Text Mining
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 11 • Developing Graphical User Interfaces With tkinter
  • Learning Objectives
  • Introduction
  • tkinter Background
  • tkinter Widgets
  • tkinter Layout Manager
  • Examples Placing Different Widgets
  • Writing Python Code to Work With tkinter Widgets
  • Example Program Using Three tkinter Windows
  • GUI-Based Database Application
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References

Appendix A • Links to Other Resources

Appendix A • Links to Other Resources

Appendix B • Debugging Using IDLE Debug Mode

Appendix B • Debugging Using IDLE Debug Mode

Appendix C • Timing Code Execution

Appendix C • Timing Code Execution

Appendix D • Solutions to Stop, Code, and Understand! Exercises

Appendix D • Solutions to Stop, Code, and Understand! Exercises

Description

Would you like to gather big datasets, analyze them, and visualize the results, all in one program? If this describes you, then Introduction to Python Programming for Business and Social Science Applications is the book for you. Authors Frederick Kaefer and Paul Kaefer walk you through each step of the Python package installation and analysis process, with frequent exercises throughout so you can immediately try out the functions you’ve learned. Written in straightforward language for those with no programming background, this book will teach you how to use Python for your research and data analysis. Instead of teaching you the principles and practices of programming as a whole, this application-oriented text focuses on only what you need to know to research and answer social science questions. The text features two types of examples, one set from the General Social Survey and one set from a large taxi trip dataset from a major metropolitan area, to help readers understand the possibilities of working with Python. Chapters on installing and working within a programming environment, basic skills, and necessary commands will get you up and running quickly, while chapters on programming logic, data input and output, and data frames help you establish the basic framework for conducting analyses. Further chapters on web scraping, statistical analysis, machine learning, and data visualization help you apply your skills to your research. More advanced information on developing graphical user interfaces (GUIs) help you create functional data products using Python to inform general users of data who don’t work within Python.


 First there was IBM® SPSS®, then there was R, and now there's Python. Statistical software is getting more aggressive - let authors Frederick Kaefer and Paul Kaefer help you tame it with Introduction to Python Programming for Business and Social Science Applications.



Contents

Preface

Preface

Figures and Tables in the Text Related to the GSS Data Set

Figures and Tables in the Text Related to the GSS Data Set

Figures and Tables in the Text Related to the Taxi Trips Data Set

Figures and Tables in the Text Related to the Taxi Trips Data Set

Python Modules and Packages

Python Modules and Packages

Acknowledgments

Acknowledgments

About the Authors

  • Chapter 1 • Introduction to Python
  • Learning Objectives
  • Introduction
  • Brief Introduction to Python and Programming
  • Setting Up a Python Development Environment
  • Executing Python Code in the IDLE Shell Window
  • Executing Python Code in Files
  • Package Managers
  • Data Sets Used Throughout the Book
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 2 • Building Blocks of Programming
  • Learning Objectives
  • Introduction
  • Good Programming Practice
  • Basic Elements of Python Code
  • Python Code Statements
  • Errors
  • Functions
  • Using Modules of Python Code
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 3 • Further Foundations of Python Programming
  • Learning Objectives
  • Introduction
  • Compound Data Types
  • Lists
  • String Objects
  • Sequence Operations
  • Tuples
  • Dictionaries
  • Example Using Tuples and Dictionaries
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 4 • Control Logic and Loops
  • Learning Objectives
  • Introduction
  • Conditions
  • Conditional Logic
  • Loops
  • Error Handling
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 5 • Reading and Writing to Files Using Python
  • Learning Objectives
  • Introduction
  • Data Input/Output: Using files
  • CSV Files
  • Exporting Our Results
  • Working With Database Files
  • Developing an Interactive Application Using a Database
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • Discussion Questions
  • References
  • Chapter 6 • Preparing and Working With Data Using Pandas
  • Learning Objectives
  • Introduction
  • NumPy
  • Pandas Data Structures
  • Creating Dummy Variables
  • Chapter Summary
  • Glossary
  • Discussion Questions
  • End of Chapter Exercises
  • References
  • Chapter 7 • Obtaining Data From the Web Using Python
  • Learning Objectives
  • Introduction
  • HTML: The Language of the Web
  • Using Python to Read From HTML Files
  • Obtaining GSS Data From the Web: A More Complicated Process
  • Ethical Issues: Inappropriate Use of Web Resources
  • Beautiful Soup
  • JSON: Obtaining Well-Structured Data
  • REST API Queries: A Standardized Way to Access Well-Structured Data
  • Chapter Summary
  • Glossary
  • Discussion Questions
  • End of Chapter Exercises
  • References
  • Chapter 8 • Statistical Calculations Using Python
  • Learning Objectives
  • Introduction
  • Ethical Issues: Considerations When Working With Statistics and Building Models
  • Basic Statistics
  • Using Statistical Modules
  • Pandas Features
  • SciPy Stats Module
  • Statsmodels Module for Multiple Regression
  • Statsmodels Module for Logistic Regression
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 9 • Data Visualization Using Python
  • Learning Objectives
  • Introduction
  • Data Visualization
  • Matplotlib: A Python Library to Visualize Your Data
  • Customizing Matplotlib Plots
  • Creating 3D Plots
  • Using Seaborn Package for Statistical Data Visualization
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 10 • Machine Learning and Text Mining
  • Learning Objectives
  • Introduction
  • Machine Learning
  • Supervised Learning
  • Unsupervised Learning
  • Using Python for Text Mining
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 11 • Developing Graphical User Interfaces With tkinter
  • Learning Objectives
  • Introduction
  • tkinter Background
  • tkinter Widgets
  • tkinter Layout Manager
  • Examples Placing Different Widgets
  • Writing Python Code to Work With tkinter Widgets
  • Example Program Using Three tkinter Windows
  • GUI-Based Database Application
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References

Appendix A • Links to Other Resources

Appendix A • Links to Other Resources

Appendix B • Debugging Using IDLE Debug Mode

Appendix B • Debugging Using IDLE Debug Mode

Appendix C • Timing Code Execution

Appendix C • Timing Code Execution

Appendix D • Solutions to Stop, Code, and Understand! Exercises

Appendix D • Solutions to Stop, Code, and Understand! Exercises

SAGE Publishing Logo

Introduction to Python Programming for Business and Social Science Applications


August 2020 | 392 pages | Sage US

Format Published Date ISBN Price

Would you like to gather big datasets, analyze them, and visualize the results, all in one program? If this describes you, then Introduction to Python Programming for Business and Social Science Applications is the book for you. Authors Frederick Kaefer and Paul Kaefer walk you through each step of the Python package installation and analysis process, with frequent exercises throughout so you can immediately try out the functions you’ve learned. Written in straightforward language for those with no programming background, this book will teach you how to use Python for your research and data analysis. Instead of teaching you the principles and practices of programming as a whole, this application-oriented text focuses on only what you need to know to research and answer social science questions. The text features two types of examples, one set from the General Social Survey and one set from a large taxi trip dataset from a major metropolitan area, to help readers understand the possibilities of working with Python. Chapters on installing and working within a programming environment, basic skills, and necessary commands will get you up and running quickly, while chapters on programming logic, data input and output, and data frames help you establish the basic framework for conducting analyses. Further chapters on web scraping, statistical analysis, machine learning, and data visualization help you apply your skills to your research. More advanced information on developing graphical user interfaces (GUIs) help you create functional data products using Python to inform general users of data who don’t work within Python.


 First there was IBM® SPSS®, then there was R, and now there's Python. Statistical software is getting more aggressive - let authors Frederick Kaefer and Paul Kaefer help you tame it with Introduction to Python Programming for Business and Social Science Applications.




Table Of Contents:

  • Preface
  • Figures and Tables in the Text Related to the GSS Data Set
  • Figures and Tables in the Text Related to the Taxi Trips Data Set
  • Python Modules and Packages
  • Acknowledgments
  • About the Authors
  • Chapter 1 • Introduction to Python
  • Learning Objectives
  • Introduction
  • Brief Introduction to Python and Programming
  • Setting Up a Python Development Environment
  • Executing Python Code in the IDLE Shell Window
  • Executing Python Code in Files
  • Package Managers
  • Data Sets Used Throughout the Book
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 2 • Building Blocks of Programming
  • Learning Objectives
  • Introduction
  • Good Programming Practice
  • Basic Elements of Python Code
  • Python Code Statements
  • Errors
  • Functions
  • Using Modules of Python Code
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 3 • Further Foundations of Python Programming
  • Learning Objectives
  • Introduction
  • Compound Data Types
  • Lists
  • String Objects
  • Sequence Operations
  • Tuples
  • Dictionaries
  • Example Using Tuples and Dictionaries
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 4 • Control Logic and Loops
  • Learning Objectives
  • Introduction
  • Conditions
  • Conditional Logic
  • Loops
  • Error Handling
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 5 • Reading and Writing to Files Using Python
  • Learning Objectives
  • Introduction
  • Data Input/Output: Using files
  • CSV Files
  • Exporting Our Results
  • Working With Database Files
  • Developing an Interactive Application Using a Database
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • Discussion Questions
  • References
  • Chapter 6 • Preparing and Working With Data Using Pandas
  • Learning Objectives
  • Introduction
  • NumPy
  • Pandas Data Structures
  • Creating Dummy Variables
  • Chapter Summary
  • Glossary
  • Discussion Questions
  • End of Chapter Exercises
  • References
  • Chapter 7 • Obtaining Data From the Web Using Python
  • Learning Objectives
  • Introduction
  • HTML: The Language of the Web
  • Using Python to Read From HTML Files
  • Obtaining GSS Data From the Web: A More Complicated Process
  • Ethical Issues: Inappropriate Use of Web Resources
  • Beautiful Soup
  • JSON: Obtaining Well-Structured Data
  • REST API Queries: A Standardized Way to Access Well-Structured Data
  • Chapter Summary
  • Glossary
  • Discussion Questions
  • End of Chapter Exercises
  • References
  • Chapter 8 • Statistical Calculations Using Python
  • Learning Objectives
  • Introduction
  • Ethical Issues: Considerations When Working With Statistics and Building Models
  • Basic Statistics
  • Using Statistical Modules
  • Pandas Features
  • SciPy Stats Module
  • Statsmodels Module for Multiple Regression
  • Statsmodels Module for Logistic Regression
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 9 • Data Visualization Using Python
  • Learning Objectives
  • Introduction
  • Data Visualization
  • Matplotlib: A Python Library to Visualize Your Data
  • Customizing Matplotlib Plots
  • Creating 3D Plots
  • Using Seaborn Package for Statistical Data Visualization
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 10 • Machine Learning and Text Mining
  • Learning Objectives
  • Introduction
  • Machine Learning
  • Supervised Learning
  • Unsupervised Learning
  • Using Python for Text Mining
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Chapter 11 • Developing Graphical User Interfaces With tkinter
  • Learning Objectives
  • Introduction
  • tkinter Background
  • tkinter Widgets
  • tkinter Layout Manager
  • Examples Placing Different Widgets
  • Writing Python Code to Work With tkinter Widgets
  • Example Program Using Three tkinter Windows
  • GUI-Based Database Application
  • Chapter Summary
  • Glossary
  • End of Chapter Exercises
  • References
  • Appendix A • Links to Other Resources
  • Appendix B • Debugging Using IDLE Debug Mode
  • Appendix C • Timing Code Execution
  • Appendix D • Solutions to Stop, Code, and Understand! Exercises

Recent Product Reviews:

“The text explains how to set up and program in Python language from the very basic in an easy-to-read manner with lots of graphical illustrations and example-based approaches. Clear learning objectives in the beginning of each chapter with tips and know-hows, concluding with the chapter exercises and references are very well structured for the first-time programmers without scientific backgrounds.”
Dr. David Han, The University of Texas at San Antonio
“The organization is good, and the range of topics is very adaptable to courses.”
Giovanni Vincenti, University of Baltimore
“Explains the code line by line, great examples, code is simple and clear, coverage is relevant.”
Neba Nfonsang, University of Denver
“Practical examples, content organized around practical use, clear and non-technical language.”
Hakan Islamoglu, Recep Tayyip Erdogan University

Recommendations