Last active
April 17, 2019 22:28
-
-
Save Foadsf/2be6d4105bcdccf4dc74810e1885ec3e to your computer and use it in GitHub Desktop.
example for this question
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 os | |
os.chdir(os.getcwd()) | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
sns.set() | |
from datetime import datetime, timedelta | |
from pandas.plotting import register_matplotlib_converters | |
register_matplotlib_converters() | |
#%% | |
dfs = pd.read_excel("Daily.xlsx", sheet_name = "Behnam") | |
dfs.drop(["Medication", "Sleep", "Note"], axis=1, inplace = True) | |
dfs.dropna(axis = 0, how ='any', inplace = True) | |
dfs['Date'] = pd.to_datetime(dfs['Date'], format = '%d-%m-%y') | |
#%% | |
dfs = dfs.melt('Date', var_name = 'cols', value_name = 'vals') | |
# ax = sns.lineplot(x = dfs.index, y = 'Mood', data = dfs) | |
ax = sns.lineplot(x = "Date", y = 'vals', hue = 'cols', style = 'cols', markers = True, dashes = False, data = dfs) | |
# ax = sns.factorplot(x = "Date", y = 'vals', hue = 'cols', data = dfs) | |
ax.set_xticklabels(dfs['Date'].dt.strftime('%d-%m-%Y')) | |
plt.xticks(rotation = -90) | |
plt.tight_layout() | |
plt.show() | |
#%% |
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
+-------+------------+-----+------+------+------+------+-----+ | |
| Index | Date | AA | BB | CC | DD | EE | FF | | |
+-------+------------+-----+------+------+------+------+-----+ | |
| 0 | 2019-01-15 | 0.0 | -1.0 | 0.0 | 0.0 | 0.0 | 2.0 | | |
| 1 | 2019-01-17 | 0.0 | -1.0 | -1.0 | -1.0 | 0.0 | 2.0 | | |
| 2 | 2019-01-22 | 1.0 | -1.0 | 1.0 | -1.0 | 0.0 | 2.0 | | |
| 3 | 2019-01-24 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 2.0 | | |
| 4 | 2019-01-29 | 1.0 | 0.0 | -1.0 | 0.0 | -1.0 | 2.0 | | |
| 5 | 2019-01-31 | 0.0 | -1.0 | 0.0 | 0.0 | 0.0 | 2.0 | | |
| 6 | 2019-02-05 | 1.0 | 1.0 | 1.0 | 0.0 | 1.0 | 2.0 | | |
| 7 | 2019-02-12 | 2.0 | 1.0 | 1.0 | 0.0 | 2.0 | 2.0 | | |
+-------+------------+-----+------+------+------+------+-----+ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment