Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib.dates as mdates
- import matplotlib as mpl
- import seaborn as sns
- from datetime import datetime
- %matplotlib inline
- import warnings; warnings.filterwarnings(action='once')
- df = pd.read_excel("CDS Detail - 2019 05 22 - sample.xlsx")
- df.head()
- Date Status Method Volume
- 2018-05-10 20:45:28 F Discretionary 1
- 2018-05-03 21:09:10 F Discretionary 1
- 2018-05-17 14:19:47 F Discretionary 1
- 2018-05-17 14:21:17 F Discretionary 1
- 2018-05-17 14:19:47 F Discretionary 1
- df = df[df['Date'].notnull()]
- df.columns
- Index(['Status', 'Method', 'Volume', 'Date'], dtype='object')
- df.dtypes
- Status object
- Method object
- Volume int64
- Date datetime64[ns]
- dtype: object
- df.head()
- Status Method Volume Date
- 0 F Discretionary 1 2018-05-10 20:45:28
- 1 F Discretionary 1 2018-05-03 21:09:10
- 2 F Discretionary 1 2018-05-17 14:19:47
- 3 F Discretionary 1 2018-05-17 14:21:17
- 4 F Discretionary 1 2018-05-17 14:19:47
- df = df.set_index('Date')
- df.head()
- Status Method Volume
- Date
- 2018-05-10 20:45:28 F Discretionary 1
- 2018-05-03 21:09:10 F Discretionary 1
- 2018-05-17 14:19:47 F Discretionary 1
- 2018-05-17 14:21:17 F Discretionary 1
- 2018-05-17 14:19:47 F Discretionary 1
- weekly = df.resample(rule='W').sum()
- weekly
- Date Volume
- 2018-04-08 7
- 2018-04-15 10
- 2018-04-22 40
- 2018-04-29 69
- 2018-05-06 128
- 2018-05-13 380
- 2018-05-20 464
- 2018-05-27 6052
- 2018-06-03 6095
- 2018-06-10 6224
- 2018-06-17 3084
- 2018-06-24 5
- sns.lineplot(data = weekly, hue = 'Method')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement