From bc800a2fd4d98b4264e1f0248e5f7637ba7d896d Mon Sep 17 00:00:00 2001 From: Kristian Rother Date: Thu, 24 Aug 2023 16:56:24 +0200 Subject: [PATCH] remove excess files --- appendix/matplotlib.md | 83 ----------------------------------- appendix/pandas.md | 52 ---------------------- appendix/re.md | 66 ---------------------------- appendix/time.md | 29 ------------ index.rst | 2 +- appendix/links.md => links.md | 0 6 files changed, 1 insertion(+), 231 deletions(-) delete mode 100644 appendix/matplotlib.md delete mode 100644 appendix/pandas.md delete mode 100644 appendix/re.md delete mode 100644 appendix/time.md rename appendix/links.md => links.md (100%) diff --git a/appendix/matplotlib.md b/appendix/matplotlib.md deleted file mode 100644 index 0d8154d..0000000 --- a/appendix/matplotlib.md +++ /dev/null @@ -1,83 +0,0 @@ - -# matplotlib - -## What is matplotlib? - -`matplotlib` is a Python module for creating diagrams. - - -## Exercises - -### Exercise 1 - -Run the code to create a line plot: - - from pylab import figure, plot, savefig - - xdata = [1, 2, 3, 4] - ydata = [1.25, 2.5, 5.0, 10.0] - - figure() - plot(xdata, ydata, "r-") - savefig('simple_plot.png') - -### Exercise 2 - -Run the code to create a pie chart: - - from pylab import figure, title, pie, savefig - - names = ['Emily', 'Hannah', 'Madison', 'Ashley', 'Sarah'] - count = [25952,23073, 19967, 17995, 17687] - explode = [0.0, 0.0, 0.0, 0.05, 0.05] - - colors = ["#f0f0f0", "#dddddd", "#bbbbbb", "#999999", "#444444"] - - def get_percent(value): - '''Formats float values in pie slices to percent.''' - return "%4.1f%%" % (value) - - figure(1) - title('frequency of top 5 girls names in 2000') - pie(count, explode=explode, labels=names, shadow=True, - colors=colors, autopct=get_percent) - savefig('piechart.png', dpi=150) - -### Exercise 3 - -Run the code to create a bar plot: - - from pylab import figure, title, xlabel, ylabel, xticks, bar, \ - legend, axis, savefig - - nucleotides = ["A", "G", "C", "U"] - - counts = [ - [606, 1024, 759, 398], - [762, 912, 639, 591], - ] - - figure() - title('RNA nucleotides in the ribosome') - xlabel('RNA') - ylabel('base count') - - x1 = [2.0, 4.0, 6.0, 8.0] - x2 = [x - 0.5 for x in x1] - - xticks(x1, nucleotides) - - bar(x1, counts[1], width=0.5, color="#cccccc", label="E.coli 23S") - bar(x2, counts[0], width=0.5, color="#808080", label="T.thermophilus 23S") - - legend() - axis([1.0, 9.0, 0, 1200]) - savefig('barplot.png') - -### Exercise 4 - -Write a program creating a line plot for the frequency of one name over several years. - -## Where to learn more? - -You can find example diagrams and code in the matplotlib gallery on [matplotlib.org/gallery.html](http://matplotlib.org/gallery.html). \ No newline at end of file diff --git a/appendix/pandas.md b/appendix/pandas.md deleted file mode 100644 index f162bbd..0000000 --- a/appendix/pandas.md +++ /dev/null @@ -1,52 +0,0 @@ - -# pandas - -## What is pandas? - -`pandas` is a Python library for efficient handling of tables. - -## Installation - -Write in the command line: - - `pip install pandas` - -## Exercises - -### Exercise 1 - -Execute the following program: - - import pandas as pd - - girls = [] - for year in range(1880, 2015): - fn = "names/yob%i.txt" % year - df = pd.read_csv(PATH + fn, names=['gender', year], index_col=0) - girl = df[df.gender=='F'][year] - girls.append(girl) - - girls = pd.DataFrame(girls).fillna(0) - -### Exercise 2 - -Write the content of the variables to the screen by adding `print` statements. Explain what it does. - - -### Exercise 3 - -Add the following lines to the program. Explain them. - - tgirls = girls.transpose() - tgirls['sum'] = girls.apply(sum) - -### Exercise 4 - -Add the following lines to the program. Explain them. - - tgirls = tgirls[tgirls['sum'] >= 1000] - tgirls.to_csv('girls_1000.csv') - -### Exercise 5 - -Add lines to conduct a similar analysis of boys' names. diff --git a/appendix/re.md b/appendix/re.md deleted file mode 100644 index 72da1d6..0000000 --- a/appendix/re.md +++ /dev/null @@ -1,66 +0,0 @@ - -# re - -## What is re? - -`re` is a Python module for *Regular Expressions*. Regular expressions help you to search and replace text using sophisticated patterns. - -## Searching - - import re - - text = 'all ways lead to Rome' - - # find one occurence - print(re.search('R...\s', text)) - - # find every occurence - print(re.findall('\s(.o)', text)) - -## Replacing - - re.sub('R[meo]+', 'London', text) - -### How to find the right pattern for your problem: -Finding the right RegEx requires lots of trial-and-error search. You can test regular expressions online before including them into your program: -[www.regexplanet.com/simple/](http://www.regexplanet.com/simple/) - -### Characters used in RegEx patterns: -Some of the most commonly used characters in Regular Expression patterns are: - - \d - decimal character [0..9] - \w - alphanumeric [a..z] or [0..9] - \A - start of the text - \Z - end of the text - [ABC] - one of characters A,B,C - . - any character - ^A - not A - a+ - one or more of pattern a - a* - zero or more of pattern a - a|b - either pattern a or b matches - \s - empty space - -### Ignoring case -If the case of the text should be ignored during the pattern matching, add `re.IGNORECASE` to the parameters of any `re` function. - -## Exercises - -### Exercise 1 - -Write six patterns that extract all names from the following string: - - "In the class were three girls: Thelma, Emma and - Sophia. Also three boys: Emmett and his best friends - Sophocles and Theophilius" - -### Exercise 2 - -Reduce the number of patterns you need to three. - -### Exercise 3 - -Find all six names using a single pattern. - -## Where to learn more about Regular Expressions? - -see [www.regexone.com](http://www.regexone.com) diff --git a/appendix/time.md b/appendix/time.md deleted file mode 100644 index 19135dc..0000000 --- a/appendix/time.md +++ /dev/null @@ -1,29 +0,0 @@ - -# time and datetime - -The `time` module offers functions for getting the current time and date. - - import time - s = time.asctime() - i = time.time() - -The `datetime` module helps you to represent dates and format them nicely: - - date = datetime.date(2015, 12, 24) - date.strftime("%d.%m.%Y") - -Dates can be converted to integer numbers: - - date = datetime.date(2015, 12, 24) - number = date.toordinal() - -and back - - datetime.date.fromordinal(7) - -## Exercises - -### Exercise 1 - -Print today's date and time of day in a custom format. - diff --git a/index.rst b/index.rst index 2894fb1..e07c723 100644 --- a/index.rst +++ b/index.rst @@ -145,7 +145,7 @@ Appendix .. toctree:: :maxdepth: 1 - appendix/links.md + links.md -------------- diff --git a/appendix/links.md b/links.md similarity index 100% rename from appendix/links.md rename to links.md