Chapter 1. Python for Data Science

In this chapter, we will cover the following recipes:

  • Using dictionary objects
  • Working with a dictionary of dictionaries
  • Working with tuples
  • Using sets
  • Writing a list
  • Creating a list from another list - list comprehension
  • Using iterators
  • Generating an iterator and a generator
  • Using iterables
  • Passing a function as a variable
  • Embedding functions in another function
  • Passing a function as a parameter
  • Returning a function
  • Altering the function behavior with decorators
  • Creating anonymous functions with lambda
  • Using the map function
  • Working with filters
  • Using zip and izip
  • Processing arrays from the tabular data
  • Preprocessing the columns
  • Sorting lists
  • Sorting with a key
  • Working with itertools

Introduction

The Python programming language provides a lot of built-in data structures and functions that are very handy for data science programming. In this chapter, we will look at some that are most frequently used. In the subsequent chapters, you will see that these will be used in various sections for different topics. A good grasp of these will help you in the long run to quickly bootstrap a program in order to handle data and develop algorithms.

While this chapter is a quick overview of handy data structures and methods, you will start discovering your own ways of combining these data structures to achieve your requirements as you become a seasoned Python user.

Each of these data structures have an utility, though different circumstances may require using two or more data structures in tandem to achieve your requirements. You will see this in action in some of the examples in this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset