Skip to content

Instantly share code, notes, and snippets.

View Ze1598's full-sized avatar

José Fernando Costa Ze1598

  • Porto, Portugal
View GitHub Profile
@Ze1598
Ze1598 / apa_citations.py
Last active April 5, 2020 15:54
Find APA style-cited documents in Word (.docx) files
"""
Citation examples used in the sample text (random authors and titles with random dates)
(Sabbagh, 2009)
(Sabbagh, n.d.)
(Sabbagh, 2010a)
(Sabbagh, 2010b)
(Qianyi Gu & Sumner, 2006)
(Despotovic-Zrakic et al., 2012)
(Anonymous, 2010)
(Anonymous, n.d.)
@Ze1598
Ze1598 / my_citations.py
Last active April 5, 2020 15:42
Find cited documents in Word (.docx) files
"""
Citation examples:
("Learning Analytics - Definitions, Processes and Potential", p. 2)
("Wanted: A road map for understanding Integrated Learning Systems")
"""
import docx2txt as docx
import re
# Open the document
text = docx.process("my_lorem_sample.docx")
@Ze1598
Ze1598 / helper_data.txt
Created January 22, 2020 17:02
Worksheet of fake sale data: helper data
Sales people:
Lyndsey Britt
Humphrey Barr
Mathew Rudd
Gianluca Fenton
Alfie-Lee Schultz
Amarah Mccarty
Douglas Povey
Dulcie Squires
Haydon Fisher
@Ze1598
Ze1598 / fill_between_demo.py
Created January 15, 2020 20:02
Matplotlib intro: fill between
from matplotlib import pyplot as plt
import numpy as np
days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Need to save the data for the Y axis as NumPy arrays because the\
# `fill_between()` method needs to receive arrays instead of lists
company_sales = np.array([2, 6, 9, 12, 8, 15, 20, 32, 27, 30])
competition_sales = np.array([1, 2, 4, 5, 13, 12, 18, 22, 34, 38])
plt.plot(days, company_sales, color="blue", label="Company A")
@Ze1598
Ze1598 / histogram_demo.py
Created January 15, 2020 20:00
Matplotlib intro: histogram
from matplotlib import pyplot as plt
ages = [83, 50, 88, 31, 37, 52, 81, 58, 23, 60, 51, 62, 36, 95, 64, 59, 91, 70, 35,
94, 61, 65, 96, 21, 95, 78, 99, 33, 29, 35, 29, 98, 54, 48, 97, 41, 29, 82,
67, 55, 37, 99, 20, 69, 70, 98, 88, 41, 30, 58, 96, 33, 25, 52, 40, 69, 40,
32, 50, 51, 64, 57, 75, 87, 37, 37, 82, 68, 65, 96, 45, 27, 52, 86, 51, 45,
52, 67, 72, 98, 84, 76, 43, 26, 44, 41, 58, 19, 84, 21, 87, 46, 84, 76, 61,
74, 32, 58, 66, 29]
bins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
@Ze1598
Ze1598 / bar_hor_chart_demo.py
Created January 15, 2020 19:57
Matplotlib intro: horizontal bar chart
from matplotlib import pyplot as plt
pairs_owned = [16, 9, 9, 6]
options = ["One", "Two", "Three", "Four+"]
plt.barh(options, pairs_owned)
plt.title("Years of experience working with Python (n=40)")
plt.xlabel("Number of respondents")
plt.tight_layout()
@Ze1598
Ze1598 / bar_chart_demo.py
Created January 15, 2020 19:55
Matplotlib intro: bar chart
from matplotlib import pyplot as plt
pairs_owned = [16, 9, 9, 6]
options = ["One", "Two", "Three", "Four+"]
plt.bar(options, pairs_owned)
plt.title("Years of experience working with Python (n=40)")
plt.ylabel("Number of respondents")
plt.tight_layout()
@Ze1598
Ze1598 / pie_chart_demo.py
Last active January 16, 2020 23:38
Matplotlib intro: pie charts
from matplotlib import pyplot as plt
slices = [1, 9, 3, 3, 4]
labels = ["Management", "Sales", "Quality Assurance", "Accounting", "Human Resources"]
colors = ["#ff9999", "#66b3ff", "#99ff99", "#ffcc99", "#cccccc"]
plt.pie(slices, labels=labels, colors=colors, autopct="%1.2f%%")
plt.title("Size of departments at Company A")
plt.tight_layout()
@Ze1598
Ze1598 / scatter_plot_demo.py
Created January 15, 2020 19:46
Matplotlib intro: scatter plots
from matplotlib import pyplot as plt
x_coords = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
fav_nums = [9, 37, 45, 32, 46, 56, 28, 9, 16, 68, 64, 100, 25, 1, 59, 50, 31, 96, 13, 76]
plt.scatter(x_coords, fav_nums, marker="x", color="red")
plt.ylabel("Favorite number")
plt.xticks([])
plt.title("Favorite number of twenty individuals")
@Ze1598
Ze1598 / line_plot_demo.py
Last active January 16, 2020 23:38
Matplotlib intro: line plots
from matplotlib import pyplot as plt
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
doubles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
squares = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
plt.plot(nums, doubles, label="Doubles", color="red")
plt.plot(nums, squares, label="Squares", color="blue")
plt.xlabel("Number")