# AUTOGENERATED! DO NOT EDIT! File to edit: notebooks/EnochPratt_Libcard.ipynb (unless otherwise specified).

__all__ = ['fdf', 'findf', 'findf', 'findf']

# Cell
%%capture
# export
# @title Run: Import Modules

# These imports will handle everything
import os
import sys
import csv
from IPython.display import clear_output
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import geopandas as gpd
from geopandas import GeoDataFrame
import psycopg2
import pyproj
from pyproj import Proj, transform
# conda install -c conda-forge proj4
from shapely.geometry import Point
from shapely.geometry import LineString
from shapely import wkb
from shapely.wkt import loads
# https://pypi.org/project/geopy/
from geopy.geocoders import Nominatim
import folium
from folium import plugins

from dataplay.merge import mergeDatasets

import dexplot as dxp

# In case file is KML, enable support
import fiona
fiona.drvsupport.supported_drivers['kml'] = 'rw'
fiona.drvsupport.supported_drivers['KML'] = 'rw'

# Cell
fdf = geoms.workWithGeometryData(method='pinp', df=gdf, polys=csa_gdf, ptsCoordCol='geometry', polygonsCoordCol='geometry', polyColorCol=False, polygonsLabel='RecordsInCsa', pntsClr='red', polysClr='white')
findf = fdf.copy()
findf = findf[['CSA2010', 'tpop10', 'pointsinpolygon', 'geometry']]
findf['libcard19'] = findf['pointsinpolygon'] / findf['tpop10'] * 1000

# Cell
findf = findf.append({
    'CSA2010': 'Baltimore City',
    'tpop10': findf['tpop10'].sum(),
    'pointsinpolygon': findf['pointsinpolygon'].sum(),
    'geometry': 'na',
    'libcard19': (findf['pointsinpolygon'].sum() / findf['tpop10'].sum() * 1000), }, ignore_index=True)

# Cell
%%capture
# export
# @title Run: Import Modules

# These imports will handle everything
import os
import sys
import csv
from IPython.display import clear_output
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import geopandas as gpd
from geopandas import GeoDataFrame
import psycopg2
import pyproj
from pyproj import Proj, transform
# conda install -c conda-forge proj4
from shapely.geometry import Point
from shapely.geometry import LineString
from shapely import wkb
from shapely.wkt import loads
# https://pypi.org/project/geopy/
from geopy.geocoders import Nominatim
import folium
from folium import plugins

from dataplay.merge import mergeDatasets

import dexplot as dxp

# In case file is KML, enable support
import fiona
fiona.drvsupport.supported_drivers['kml'] = 'rw'
fiona.drvsupport.supported_drivers['KML'] = 'rw'