I'm graphing with plotly and I want to streamline the process
This is the current plot below: 
I want to filter the data and have it done by extracting the first of each month and then associating single letter abbreviation with it.
Goal have the output formatted like this for easy implementation to plotly so all I have to do is run the month filter script over a csv file, have it print the below code to then be copied into my plotting script.
ticktext = ('O','N','D', \
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A'),
tickvals=('10/1/3014','11/1/2014', "12/1/2014....8/1/2019"),
So far this is what I have:
#Days since
# dates need to be yyyy-MM-dd for easy transfer from pc to pc
import pandas as pd
import numpy as np
import datetime as dt
from time import strptime
df = pd.read_csv('/content/drive/.csv',sep = ',',encoding='utf-8-sig',)
df['Date'] = pd.to_datetime(df['Date'])
df['Month'] = pd.to_datetime(df['Date'], format='%m').dt.month_name().str.slice(stop=1)
#Calculate the singular day
Days = (df['Date']).dt.day
df['Day_of_Month'] = Days
df = df[df['Day_of_Month'] == 1]
print(df)
Sample of data
This is where I get stuck.
sliced_by_index = df.iloc[:, 0] #Date
liced_by_index = df.iloc[:, 18] # abrivations
Need to find a way to print in exact format mentioned
ticktext = ('O','N','D', \
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A','S','O','N','D',\
'J','F','M','A','M','J','J','A'),
tickvals=('10/1/3014','11/1/2014', "12/1/2014....8/1/2019"),
[![enter image description here][3]][3]
Thanks!

Aucun commentaire:
Enregistrer un commentaire