Python setup
In early January, we’ll create an installation guide for R and RStudio (based on this one: https://iqss.github.io/dss-workshops/Rinstall.html), together with instructions for installing packages, so that all participants can arrive with working Python environments.
Here, we create a Conda environment using the bash
shell to install all necessary packages:
# locally build pyDataverse
conda skeleton pypi pyDataverse
conda build pyDataverse
# create a new virtual environment and activate it
conda create -n datafest
conda activate datafest
# install pyDataverse from local build
conda install --use-local pyDataverse
# install all other modules after installing pyDataverse
conda install requests pandas geopandas numpy matplotlib seaborn descartes bokeh statsmodels
# math, functools, and warnings modules are in the Python standard library
Now, we can load the necessary packages for the current material:
from pyDataverse.api import Api
from pyDataverse.models import Dataverse
import pandas as pd
import numpy as np
import requests
from functools import reduce
import matplotlib.pyplot as plt
import math
import seaborn as sns
# for maps
import descartes
import geopandas
from mpl_toolkits.axes_grid1 import make_axes_locatable
from bokeh.plotting import figure, save, show, output_file
from bokeh.models import ColumnDataSource, HoverTool, LogColorMapper, ColorBar
from bokeh.palettes import Viridis256 as palette
# for models
import warnings
warnings.filterwarnings("ignore")
import statsmodels.api as sm
import scipy.stats as stats
from statsmodels.stats.outliers_influence import OLSInfluence as influence
import statsmodels.formula.api as smf
from statsmodels.genmod.bayes_mixed_glm import PoissonBayesMixedGLM
from scipy.stats.distributions import chi2
from statsmodels.genmod.generalized_estimating_equations import GEE
from statsmodels.genmod.cov_struct import (Exchangeable, Autoregressive)
from statsmodels.genmod.families import (Poisson, NegativeBinomial)