Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 2116
Image: ubuntu2004
Kernel: Python 3

Exercise 1.1: Firefly flashes

The data in the file FireflyFlash.csv are flash durations in milliseconds of a sample of male fireflies of the species Photinus ignitus.

  1. Read the data into a pandas DataFrame and call it something sensible, like fireflies, for example.

  2. Print the data.

  3. Print the first 5 rows of data only.

  4. Print the number of fireflies in the dataset.

  5. Print the name of the variable in the dataset.

import pandas as pd fireflies = pd.read_csv('FireflyFlash.csv') fireflies
# First five rows print(fireflies.head(5)) # Number of fireflies print(f'Number of fireflies is {len(fireflies)}') # Variable name print(fireflies.columns.values)

Exercise 1.2: Swimming in syrup

Can a human swim faster in water or in syrup? It is unknown whether the increase in the friction of the body moving through the syrup (slowing the swimmer down) is compensated by the increased power of each stroke (speeding the swimmer up). Finally, an experiment was done by Gettelfinger and Cussler (2004) in which they filled one pool with water mixed with syrup (guar gum) and another pool with normal water. They had 18 swimmers swim laps in both pools in random order. The data (in the file SyrupSwimming.csv) are presented as the relative speed of each swimmer in syrup (speed in the syrup pool divided by his or her speed in the water pool). If the syrup has no effect on swimming speed, then relative swim speed should have a mean of 1.

  1. Read the data into a pandas DataFrame.

  2. Print the data.

  3. Print the last 3 rows of data only.

  4. Print the number of swimmers in the dataset.

  5. Print the name of the variable in the dataset.

rel_speed = pd.read_csv('SyrupSwimming.csv') rel_speed
# Last three rows print(rel_speed.tail(3)) # Number of swimmers print(f'Number of swimmers is {len(rel_speed)}') # Variable name print(rel_speed.columns.values)