This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
# white background in plots | |
sns.set(style="whitegrid") | |
# df is a pandas dataframe | |
# plot by column by variable 'var1', in 3 columns, coloring by variable 'var2' | |
grid = sns.FacetGrid(df, col='var1', col_wrap=3, hue='var2', size=4, palette='Set2') |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import | |
import numpy as np | |
import pandas as pd | |
# convert a pandas dataframe to numpy excluding a column | |
data_matrix = np.array(data[data.columns.difference(['col_to_exclude'])], dtype=float) | |
# add new column to existing dataframe from another array | |
df = df.assign(new_col=vector.values) |