Skip to main content Accessibility help
×
Hostname: page-component-848d4c4894-sjtt6 Total loading time: 0 Render date: 2024-06-29T21:00:56.290Z Has data issue: false hasContentIssue false

Appendix – Programming Concepts for Data Science

Published online by Cambridge University Press:  14 August 2020

Get access

Summary

The aim of this book is not to introduce programming, but rather to introduce data science in a way that shows that it is not difficult to move away from pre-packaged desktop software and start integrating some programming in your own analyses. This appendix includes more detail on some of the programming concepts used throughout this book, and is designed to try and help absolute beginners look more closely at the code rather than gloss over the code they come across in the book.

Like the book as a whole, the appendix is based on the idea that there is a lot that can be achieved with very little code. It is structured according to the main things you need to know to make sense of the programming in this book:

  • variables, data types

  • importing libraries

  • functions and methods

  • loops and conditionals.

Each concept is illustrated with examples from Python and R. They are not designed to be comprehensive introductions to the concepts, but rather practical introductions reflecting how they are used within the examples in this book. In the same way that similar ideas can be expressed in different ways in the same language, so it is with programming. When you start programming you will inevitably focus on writing code that works, as you progress however you will want to start writing code that is also efficient and maybe, eventually, aesthetically pleasing.

These examples are available in two notebooks on GitHub, one for the Python examples and one for the R examples: https://github.com/dpstuart/ jupyter/blob/master/Chapter_AppendixPython.ipynb and https://github.com/ dpstuart/jupyter/blob/master/Chapter_AppendixR.ipynb.

Variables, data types and other classes

Programming is about the manipulation of objects represented in a computer's memory. These objects can consist of the inbuilt data types, and newly defined classes of object. The basic data types (e.g. strings, integers and real numbers) are similar across high level languages, however more complex classes of object may be specific to a particular language. A variable's data type also determines which functions or methods can be applied to it.

Type
Chapter
Information
Publisher: Facet
Print publication year: 2020

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×