Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions categorical/script.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
import pandas as pd
import numpy as np

# Read NYC Trees Data
nyc_trees = pd.read_csv("nyc_tree_census2.csv")
# Read NYC Trees data
nyc_trees = pd.read_csv("./nyc_tree_census.csv")

size_labels_ordered = ['Small (0-3in)', 'Medium (3-10in)', 'Medium-Large (10-18in)', 'Large (18-24in)','Very large (>24in)']

nyc_trees.tree_diam_category = pd.Categorical(nyc_trees.tree_diam_category, size_labels_ordered, ordered=True)

# Calculate 25th Percentile Category
p25_tree_diam_index = np.percentile(nyc_trees.tree_diam_category.cat.codes, 25)
print(p25_tree_diam_index)

p25_tree_diam_category = size_labels_ordered[int(p25_tree_diam_index)]
print(p25_tree_diam_category)

# Calculate 75th Percentile Category
p75_tree_diam_index = np.percentile(nyc_trees.tree_diam_category.cat.codes, 75)
print(p75_tree_diam_index)

p75_tree_diam_category = size_labels_ordered[int(p75_tree_diam_index)]
print(p75_tree_diam_category)
# Table of proportions for status
tree_status_proportions = nyc_trees.status.value_counts()/len(nyc_trees['status'])