Skip to content

Instantly share code, notes, and snippets.

View Preeya0225's full-sized avatar

Preeya Sawadmanod Preeya0225

View GitHub Profile
@Preeya0225
Preeya0225 / postgres-cheatsheet.md
Created October 29, 2019 21:56 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Preeya0225
Preeya0225 / postgres-cheatsheet.md
Created October 29, 2019 21:56 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Preeya0225
Preeya0225 / understanding-word-vectors.ipynb
Created October 22, 2019 13:23 — forked from aparrish/understanding-word-vectors.ipynb
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Preeya0225
Preeya0225 / subplots_pairplot
Last active October 9, 2019 14:50
code for plotting subplots in pairplot
# Setting up subplots using Pairplot
# X-columns
# Y-column
# Setting up the height of the plot
g = sns.pairplot(df,
x_vars=['sepal width (cm)',
'petal length (cm)'],
y_vars= 'sepal length (cm)',
height = 4)
@Preeya0225
Preeya0225 / subplot_function
Last active October 9, 2019 14:46
Function that plots subplots
#Function to plot Scatterplots as subplots
def subplot_scatter(df, list_of_columns_x, y_col, list_of_titles, list_of_xlabels):
# Makes sure to have enough rows
nrows = int(np.ceil(len(list_of_columns_x)/2))
# Specified figsize, columns and rows
fig, ax = plt.subplots(nrows=nrows, ncols=2, figsize=(10, 6))
# Ravel turns a matrix into a vector, which is easier to iterate
ax = ax.ravel()
@Preeya0225
Preeya0225 / seaborn histogram edits
Last active October 9, 2019 18:26
Seaborn histogram edits
#Import Packages
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
#Plotting distribution plot with seaborn
sns.distplot(df["sepal length (cm)"])
#Addingt Title with size
plt.title("Distribution Sepal length", fontsize = 20)
@Preeya0225
Preeya0225 / Histogram_clean
Created October 8, 2019 17:58
Clean histogram plot example
#Import packages
import matplotlib.pyplot as plt
#Specify figuresize
plt.figure(figsize = (10,10))
#Plotting a histogram
plt.hist(df["sepal length (cm)"], color = "pink")
#Adding Title with size
@Preeya0225
Preeya0225 / Matplot_edits.csv
Last active July 6, 2021 02:35
List of edits for matplotlib
Method Code Comment
Histogram .hist() Only one set of data is needed
Bar Chart .bar() Input x and height
Horizontal Bar Chart .barh() Input y and height
Box Plot .boxplot() Make a box and whisker plot
Scatter Plot .scatter() A scatter plot of y vs x
Figure .fig() Adding figure
Figure size .fig(figsize=()) Adding figure size
Title .title() Adding title
Title size .title(fontsize=) Addingt title size