Introduction to Python Programming for Business and Social Science Applications. Frederick Kaefer

Чтение книги онлайн.

Читать онлайн книгу Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer страница 7

Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer

Скачать книгу

explorer or download the complete data sets (http://www.gss.norc.org/Get-The-Data). Table 1.4 presents a subset of fields from the GSS and their meaning as described in the GSS Codebook (Smith, Davern, Freese, & Hout, 1972–2016), which is available at http://gss.norc.org/get-documentation.

      The sample data shown in Table 1.5 is in ascending order of the ID value for each record. Unlike the Trip_ID in the Taxi Trips data set, the ID value is not unique in the GSS data, as we can see by the duplication of both ID 10 and ID 16 in the data in Table 1.5. In the GSS data, it is the combination of the YEAR and ID fields that is unique (we call using several fields to uniquely identify a record in a data set a composite identifier or composite key). For example, the respondent with ID 10 in YEAR 1990 is not the same as the respondent with ID 10 in YEAR 1991. Another important difference is that the data in the GSS all appear to be numeric; however, the values are not all quantitative. For example, the values for HAPPY are coded responses to a survey where 1 = very happy, 2 = pretty happy, and 3 = not too happy. Another important point is that the values for REALINC are not actually continuous (even though they might appear to be) but are discrete. These values correspond to the midpoints of income ranges specified in a survey, and the values prior to 1986 have been recoded in six-digit numbers and converted to 1986 dollars (Ligon, 1994; Smith et al., 1972–2016).

      Lessons learned: In this section, we learned about the Chicago Taxi Trips and General Social Survey data sets, which will use throughout the text.

      Chapter Summary

      In this chapter, we learned that Python is free and open-source software (FOSS) and that more than 212,000 projects with packages written in Python are available to use and modify in the Python Package Index. The specific goal of this book is to teach Python programming to those in the fields of social sciences and business to develop applications using Python packages for data analytics. We next learned how to install Python on our computer and that there are different versions of Python. We also learned that using different operating systems and different versions of Python can affect how we write and execute Python code. We then learned how to write and execute Python code in the IDLE shell window and how to write and execute Python code that we save in plain text files. Using files enables the storing and execution of many lines of code as a program that we can save and run later. We also learned how to use package managers for convenient organization and management of libraries of code. Learning to install individual packages is an important skill to take advantage of the many Python packages for both business and social sciences purposes that are available to the Python programming community. Last, we learned about the Chicago Taxi Trips and General Social Survey data sets, which we will use throughout the text.

      In the next chapter, we will cover the basic elements of Python code, using the IDLE IDE to illustrate the outcomes of executing each code example. All coding examples in the textbook (including all Stop, Code, and Understand! exercises and their solutions) are available on the companion website to download and execute. We use the figure numbers in the file names of the code examples for easy reference. These code examples are also an example of FOSS, as you can freely modify them and use them in other applications.

      Glossary

      Case sensitiveInterpreting uppercase letters (capitals) as different from lowercase letters.Free open-source software (FOSS)Inclusive term that covers both free software and open-source software.Free softwareUsers have the freedom to run, copy, distribute, study, change, and improve the software.Interactive Development Environment (IDE)Contains facilities for writing and editing code as well as testing and debugging code.ModuleA text file that contains Python code.Open-source softwareRequires that the license to use the software shall not restrict any party from selling or giving away the software as a component of a larger software distribution.PackageLibrary of code modules used/accessed by programming code.Package managerA program to install libraries of code.pipA package manager that comes already installed in Python.PlatformThe combination of a device and an operating system.Platform independentSoftware that can run on most, if not all, of the latest operating systems/computing platforms.PythonAn interpreted computer programming language.Python distributionModified package that includes additional functionality. Also referred to as an alternative bundle.SyntaxA set of rules that dictates how to specify instructions of code in a programming language.

      End-of-Chapter Exercises

       1.1 Download and install Python on your computer by going to the website https://www.python.org/downloads/ and following the instructions that correspond to the platform that you are using.

       1.2 Enter the Python command print(“Hello, World!”) at the IDLE shell command prompt on your computer after having installed Python to verify that Python was installed properly.

       1.3 Using a text editor, create a text file named helloworld.py, which has the single line of code: print(“Hello, World!”)

       1.4 Use the IDLE IDE to open the file helloworld.py that you created and execute the code in it.

      References

      Anonymous. (2018, July 21). And now for something completely different. The Economist, 428, 67–68.

      Free Software Foundation. (2019). The free software definition. Retrieved from https://www.gnu.org/philosophy/free-sw.html

      Goth, G. (2007, January/February). Sprinting toward open source development. IEEE Software, 24(1), 88–91. doi:10.1109/MS.2007.28

      Levy, J. (2017, August 12). Taxi Trips [Data file]. Retrieved from https://dev.socrata.com/foundry/data.cityofchicago.org/wrvz-psew

      Ligon, E. (1994, June). The development and use of a consistent income measure for the General Social Survey. GSS Methodological Report No. 64. Retrieved from http://gss.norc.org/Documents/reports/methodological-reports/MR064.pdf

      Marsan, J., Pare, G., & Beaudry, A. (2012). Adoption of open source software in organizations: A socio-cognitive perspective. Journal of Strategic Information Systems, 21(4), 257–273. https://doi.org/10.1016/j.jsis.2012.05.004

      Open Source Initiative. (2007, March 22). The open source definition. Retrieved from https://opensource.org/docs/osd

      Ozgur, C., Colliau, T., Rogers, G., Hughes, Z., & Myer-Tyson, E. (2017). MatLab vs. Python vs. R. Journal of Data Science, 15(3),

Скачать книгу