<jupyter_start><jupyter_text>Pre-processing Data to work with in ShinyDate Updated: 04/10/2020Purpose:  pre-processes data before use within Shiny.<jupyter_code>#Needed Libararies
import os
import numpy as np
import pandas as pd
from datetime import datetime
pd.set_option('display.max_columns', 999)  # How to display all columns of a Pandas DataFrame in Jupyter Notebook
pd.options.display.max_rows  # Increases the length of a printed string from a DataFrame
pd.set_option('display.max_colwidth', -1)
#Working Directory and Input File
workingDir = "C:/Users/rjame/Documents/RShinyAppPractice/ColoradoRiverBasin/CRBShinyAppver2/data"

os.chdir(workingDir)

data_Input = "P_dfAllo_CRBSites.csv"
#Create Dataframe
df = pd.read_csv(data_Input)
df
df.columns
#technique to check datatype of long dataframes.
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    print(df.dtypes)
#Changing datatype of used date fields. 
df['PD'] = pd.to_datetime(df['PD'], errors = 'coerce')
df['PD'] = pd.to_datetime(df["PD"].dt.strftime('%m/%d/%Y'))
df
#The Ouput
#The Shiny app is responding best to UTF-8 encoding.

df.to_csv('P_dfAllo_CRBSites.csv', index=False)  # The rows that were removed from output.<jupyter_output><empty_output>