<jupyter_start><jupyter_text>Primary Diagnoses of our Black patients with Unplanned Readmissions<jupyter_code>import numpy as np
import pandas as pd
import icd10

df = pd.read_csv("prepared_neuror2_data.csv")
mask = df.Race_BlackOrAfricanAmerican & df.UnplannedReadmission
diags = df[mask].groupby(by="PrimaryDiagnosis", as_index=False)\
             .Race_BlackOrAfricanAmerican.count().copy()
diags["description"] = diags.apply(lambda r: icd10.find(r.PrimaryDiagnosis).description, axis=1)
diags.sort_values(by="Race_BlackOrAfricanAmerican", ascending=False)
for index, r in diags.sort_values(by="Race_BlackOrAfricanAmerican", ascending=False).iterrows():
    print("%2d %8s %s" % (r.Race_BlackOrAfricanAmerican, r.PrimaryDiagnosis, r.description))
print("Total black patients", sum(df.Race_BlackOrAfricanAmerican))

drgs = [col for col in df.columns if col.startswith("DRG_")]

diags = df[mask][drgs]

print(diags.shape[0])

foo = diags.sum().sort_values(ascending=False)

print(sum(foo.values))

print ("""
| n | Diagnosis-related group (DRG) |
|:--|:------------------------------|""")

for k,v in zip(foo.index, foo.values):
    if v > 0:
        print("| %s | %s |" % (v, k[4:].replace("&","\&")))<jupyter_output>Total black patients 419
42
42

| n | Diagnosis-related group (DRG) |
|:--|:------------------------------|
| 9 | Intracranial hemorrhage or cerebral infarction w MCC |
| 4 | Craniotomy \& endovascular intracranial procedures w MCC |
| 3 | Seizures w/o MCC |
| 3 | Seizures w MCC |
| 3 | Intracranial hemorrhage or cerebral infarction w CC or tpa in 24 hrs |
| 2 | Spinal fusion except cervical w/o MCC |
| 1 | Esophagitis, gastroent \& misc digest disorders w/o MCC |
| 1 | Other antepartum diagnoses w medical complications |
| 1 | Cervical spinal fusion w CC |
| 1 | Other disorders of nervous system w MCC |
| 1 | Trach w MV >96 hrs or PDX exc face, mouth \& neck w/o maj O.R. |
| 1 | Other disorders of nervous system w CC |
| 1 | Spinal procedures w CC or spinal neurostimulators |
| 1 | Signs \& symptoms w/o MCC |
| 1 | Other vascular procedures w MCC |
| 1 | Diabetes w MCC |
| 1 | Spinal procedures w MCC |
| 1 | Spinal fus exc cerv w spinal curv/malig/infec or ext fus w CC |
| 1 | Ventric[...]
{'fraction_non_alphanumeric': 0.15325842696629213, 'fraction_numerical': 0.018426966292134833, 'mean_word_length': 3.828633405639913, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '395644', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 842, 'n_tokens_neox': 739, 'n_words': 229, 'path': 'Black Community.ipynb', 'repo_name': 'massie/readmission-study', 'size': '2225'}