VAERS DATA POINT enhancement of Mortality Reports with Plotly and Hover Text Wrap

Read Time:5 Minute, 20 Second

import pandas as pd

import numpy as np

pd.set_option(‘display.max_columns’, None)

from plotly.subplots import make_subplots

import plotly.graph_objects as go

import plotly.express as px

import warnings

import gc

warnings.filterwarnings(“ignore”)

date = pd.Timestamp.now().strftime(‘%m/%d/%Y’)

import re

gc.enable()

vdata=pd.read_csv(‘2021VAERSData.csv’, encoding=’latin1′, dtype={‘BIRTH_DEFECT’:object},low_memory=False)

vvax = pd.read_csv(‘2021VAERSVAX.csv’,encoding=’latin1′,low_memory=False)

vsymp = pd.read_csv(‘2021VAERSSYMPTOMS.csv’,encoding=’latin1′,low_memory=False)

vsymp.info()

dp =[2,4,6,8,10]

vsymp.drop(vsymp.columns[dp],axis=1, inplace=True)

c = [7,12,15,23]

vdata.drop(vdata.columns[c],axis=1, inplace=True)

v1 = vdata.merge(vvax, on=’VAERS_ID’, how=’outer’)

v1.head(1)

VAERSM = v1.merge(vsymp, on =”VAERS_ID”, how=’outer’)

VAERSM.head(1)

VAERSM = VAERSM.query(‘VAX_TYPE== “COVID19″‘)

VAERSM.to_csv(“VDUP.csv”, index=False)

del vdata

del vvax

del vsymp

del VAERSM

VDUP = pd.read_csv(‘VDUP.csv’,encoding=’latin1′,memory_map=True, low_memory=False)

test = VDUP.duplicated(subset=[“VAERS_ID”])

print(test.value_counts())

del test

VDUP.query(‘VAX_TYPE==”COVID19″‘,inplace=True) #ISOLATES VACCINE TYPE

gc.collect()

fullframe = VDUP.copy(deep=True) #Full frame will have duplicated VAERS ID

nodupids =  VDUP.drop_duplicates(subset=[‘VAERS_ID’], keep=’first’)

del VDUP

print(len(fullframe),len(nodupids))

pd.options.display.max_colwidth = 5000

nodupids[[‘VAERS_ID’,’SYMPTOM_TEXT’]].head(3)

D_nodupids = nodupids.query(‘DIED==”Y”‘)

zero_d = D_nodupids.query(‘NUMDAYS <= 1’,)

zero_d.replace({np.nan:’N’ },regex=True,inplace=True)

d_count =len(zero_d)

zero_d[“SYMPTOM_TEXT” ]=zero_d[‘SYMPTOM_TEXT’].str.wrap(100)

zero_d[‘SYMPTOM_TEXT’]= zero_d[‘SYMPTOM_TEXT’].str.replace(‘\\n’,'<br />’)

zbar= zero_d.groupby(‘AGE_YRS’)[‘DIED’].count().to_frame().reset_index()

zbar

fig = make_subplots(rows=1, cols=2,shared_yaxes=False)

fig.add_trace(

    go.Box( y=zero_d[‘AGE_YRS’], boxpoints=’all’,name=’Median Mortality’, text=zero_d[[‘AGE_YRS’,’SYMPTOM1′,’SYMPTOM2′,’SYMPTOM3′,’SYMPTOM4′,’SYMPTOM5′,’SYMPTOM_TEXT’]],hovertemplate = “AGE %{text[0]} <br> %{text[1]}  <br> %{text[2]} <br> %{text[3]} <br> %{text[4]} <br> %{text[5]} <br> %{text[6]}”),

    row=1, col=1

)

fig.add_trace(

    go.Bar(x=zbar[‘AGE_YRS’],y=zbar[“DIED”],name=’Total by Age’,width=1, text=zbar[[‘AGE_YRS’,’DIED’]],hovertemplate = “AGE %{text[0]} <br>Deaths Reported: %{text[1]}”) ,

    row=1, col=2

)

fig.update_layout(legend_traceorder=”normal”,template=’plotly_dark’,legend=dict(

        itemclick=”toggleothers”,

        itemdoubleclick=”toggle”),hoverlabel=dict(

        bgcolor=”red”,

        font_size=30,

        font_family=”Rockwell”))

fig.update_layout(font=dict(family=”Droid Sans Mono”,size=30))

fig.update_yaxes(tickfont_size=30, ticks=”outside”, ticklen=20, tickwidth=10,showspikes=True)

fig.update_xaxes(tickfont_size=30, ticks=”outside”, ticklen=20, tickwidth=10,showspikes=True)

fig.update_layout(height=1000, width=1900, title_text=f”DIED or DIED WITHIN 1 DAY OF SHOT -REPORTS TO VAERS #{d_count}”)

fig.show()

dlong = nodupids.query(‘NUMDAYS >=11 and NUMDAYS <500’)

dlong.replace(np.nan,”N”, inplace=True)

dlong[“SYMPTOM_TEXT” ]=dlong[‘SYMPTOM_TEXT’].str.wrap(100)

dlong[‘SYMPTOM_TEXT’]= dlong[‘SYMPTOM_TEXT’].str.replace(‘\\n’,'<br />’)

fig = px.scatter(dlong, x=’NUMDAYS’,y=’VAERS_ID’,color=”DIED”,hover_data=[‘SYMPTOM_TEXT’])

fig.update_layout(height=900, width=1900, title_text=f”LONG RANGE -REPORTS TO VAERS 11 Days or More as of {date}”)

fig.update_layout(legend_traceorder=”normal”,template=’plotly_dark’,legend=dict(

        itemclick=”toggleothers”,

        itemdoubleclick=”toggle”),hoverlabel=dict(

        bgcolor=”black”,

        font_size=30,

        font_family=”Rockwell”

    )   )

fig.update_layout(font=dict(family=”Droid Sans Mono”,size=30))

fig.update_xaxes(tickfont_size=30, ticks=”outside”, ticklen=20, tickwidth=10)

fig.update_yaxes(tickfont_size=30, ticks=”outside”, ticklen=20, tickwidth=10)

fig.show()

del dlong

gc.collect()

dshort = D_nodupids.query(‘NUMDAYS >=1 and NUMDAYS < 11 ‘)

dshort.replace(np.nan,”N”, inplace=True)

dshort[“SYMPTOM_TEXT” ]=dshort[‘SYMPTOM_TEXT’].str.wrap(100)

dshort[‘SYMPTOM_TEXT’]= dshort[‘SYMPTOM_TEXT’].str.replace(‘\\n’,'<br />’)

zdbar= dshort.groupby(‘AGE_YRS’)[‘DIED’].count().to_frame().reset_index()

d_count= zdbar[‘DIED’].sum()

fig = make_subplots(rows=1, cols=2,shared_yaxes=False)

fig.add_trace(

    go.Box( y=dshort[‘AGE_YRS’], boxpoints=’all’, name=’Median Mortality’, text=dshort[[‘AGE_YRS’,’SYMPTOM1′,’SYMPTOM2′,’SYMPTOM3′,’SYMPTOM4′,’SYMPTOM5′,’SYMPTOM_TEXT’]],hovertemplate = “AGE %{text[0]} <br> %{text[1]}  <br> %{text[2]} <br> %{text[3]} <br> %{text[4]} <br> %{text[5]} <br> %{text[6]}”),

    row=1, col=1

)

fig.add_trace(

    go.Bar(x=zdbar[‘AGE_YRS’],y=zdbar[“DIED”],name=’Total by Age’,width=1,text=zdbar[[‘AGE_YRS’,’DIED’]],hovertemplate = “AGE %{text[0]} <br>Deaths Reported: %{text[1]}”),

    row=1, col=2

)

fig.update_layout(legend_traceorder=”normal”,template=’plotly_dark’,legend=dict(

        itemclick=”toggleothers”,

        itemdoubleclick=”toggle”),hoverlabel=dict(

        bgcolor=”red”,

        font_size=30,

        font_family=”Rockwell”))

fig.update_layout(font=dict(family=”Droid Sans Mono”,size=30))

fig.update_yaxes(tickfont_size=30, ticks=”outside”, ticklen=20, tickwidth=10,showspikes=True)

fig.update_xaxes(tickfont_size=30, ticks=”outside”, ticklen=20, tickwidth=10,showspikes=True)

fig.update_layout(height=1000, width=2300, title_text=f”DIED or DIED WITHIN 10 DAYS OF SHOT -REPORTS TO VAERS #{d_count}”)

fig.show()

del dshort

gc.collect()



Categories: All Posts

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%
%d bloggers like this: