Posts

Showing posts with the label panda

Exercises: OESMN (Obtaining, Scrubbing, Exploring, Modeling, iNterpreting)

As part of the Data science is OSEMN module for Obtaining Data I worked through the exercises. Example Code # Exercises """http://people.duke.edu/~ccc14/sta-663/DataProcessingSolutions.html#exercises""" """1. Write the following sentences to a file “hello.txt” using open and write. There should be 3 lines in the resulting file. Hello, world. Goodbye, cruel world. The world is your oyster.""" str = 'Data\Test.txt' f = open(str, 'w') f.write('Hello, world.\r') f.write('Goodbye, cruel world.\r') f.write('The world is your oyster.') # Writes same thing, only in one statement f.write('\rHello, world.\rGoodbye, cruel world.\rThe world is your oyster.') f.close() with open(str, 'r') as f: content = f.read() print(content) """2. Using a for loop and open, print o...

OESMN (Obtaining, Scrubbing, Exploring, Modeling, iNterpreting): Getting Data

OESMN is an acronym, for the elements of data science: Obtaining data Scrubbing data Exploring data Modeling data iNterpreting data As part of the Data science is OSEMN module  for Obtaining Data I performed the examples myself, as well as with variants. Example Code # Data science is OSEMN """http://people.duke.edu/~ccc14/sta-663/DataProcessingSolutions.html#data-science-is-osemn""" # Acquiring data """Plain text files We can open plain text files with the open function. This is a common and very flexible format, but because no structure is involved, custom processing methods to extract the information needed may be necessary. Example 1: Suppose we want to find out how often the words alice and drink occur in the same sentence in Alice in Wonderland. This example uses Gutenberg: http://www.gutenberg.org/wiki/Main_Page, a good source for files""" # the data file is linked below...