diff --git a/README.md b/README.md index b21dc672..c769703b 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ In addition, the following packages are also required: - matplotlib (2.0.2) - seaborn (0.8) - numpy (1.13.1) -- scipy (0.19.1) -- pandas (0.20.3). +- scipy (1.0.0) +- pandas (0.21.0). To obtain these package dependencies easily, it is highly recommended to download the Anaconda distribution of Python from [https://www.continuum.io/downloads](https://www.continuum.io/downloads). diff --git a/dabest/main.py b/dabest/main.py index 2c45ae7e..7f3fd20b 100644 --- a/dabest/main.py +++ b/dabest/main.py @@ -237,18 +237,31 @@ def plot(data, idx, y = 'value' else: y = str(swarm_label) + if color_col is None: idv = ['index'] + turn_to_cat = [x] else: - idv = ['index',color_col] + idv = ['index', color_col] + turn_to_cat = [x, color_col] + data_in = pd.melt(data_in.reset_index(), id_vars=idv, value_vars=all_plot_groups, value_name=y, var_name=x) - idv.append(x) - idv.append(y) - data_in.columns = [idv] + + for c in turn_to_cat: + data_in.loc[:,c] = pd.Categorical(data_in[c], + categories=data_in[c].unique(), + ordered=True) + # if color_col is not None: + # data_in.loc[:,color_col] = pd.Categorical(data_in[color_col], + # categories=data_in[color_col]unique(), + # ordered=False) + # idv.append(x) + # idv.append(y) + # data_in.columns = [idv] # CALCULATE CI. if ci < 0 or ci > 100: @@ -365,15 +378,33 @@ def plot(data, idx, contrast_ax_ylim_high = list() contrast_ax_ylim_tickintervals = list() + ###### # # ##### + # # # # # # + # # # # # + ###### # # # #### + # # # # # # + # # # # # # + ###### ##### ##### + ####### # # ####### ###### + # # # # # # # + # # # # # # # + # # # # ##### ###### + # # # # # # # + # # # # # # # + ####### # ####### # # + # # ####### ###### ####### + # # # # # # + # # # # # # + ####### ##### ###### ##### + # # # # # # + # # # # # # + # # ####### # # ####### + # CREATE COLOR PALETTE TO NORMALIZE PALETTE ACROSS AXES. if color_col is None: - if isinstance(melted_data_in[x], pd.Series) is False: - raise AttributeError(melted_data_in[x].dtype) - color_groups = melted_data_in[x].unique() + color_groups = data_in[x].unique() else: - if isinstance(melted_data_in[color_col], pd.Series) is False: - raise AttributeError(melted_data_in[color_col].dtype) - color_groups = melted_data_in[color_col].unique() + color_groups = data_in[color_col].unique() if custom_palette is None: plotPal=dict( zip( color_groups, @@ -406,11 +437,10 @@ def plot(data, idx, # FOR EACH TUPLE IN IDX, CREATE PLOT. for j, current_tuple in enumerate(idx): - plotdat=data_in[data_in[x].isin(current_tuple)].copy() - plotdat.loc[:,x] = plotdat[x].astype("category") - plotdat[x].cat.set_categories(current_tuple, - ordered=True, - inplace=True) + plotdat = data_in[data_in[x].isin(current_tuple)].copy() + plotdat.loc[:,x] = pd.Categorical(plotdat[x], + categories=current_tuple, + ordered=True) plotdat.sort_values(by=[x]) summaries = plotdat.groupby(x)[y].apply(stat_func) # Compute Ns per group. diff --git a/setup.py b/setup.py index a4308e90..ff0f08be 100644 --- a/setup.py +++ b/setup.py @@ -29,10 +29,10 @@ def check_dependencies(): to_install.append('matplotlib==2.0.2') try: import pandas - if int(pandas.__version__.split('.')[1])<20: - to_install.append('pandas==0.20.3') + if int(pandas.__version__.split('.')[1])<21: + to_install.append('pandas>=0.21.0') except ImportError: - to_install.append('pandas==0.20.3') + to_install.append('pandas>=0.21.0') try: import seaborn except ImportError: @@ -46,8 +46,8 @@ def check_dependencies(): setup(name='dabest', author='Joses Ho', author_email='joseshowh@gmail.com', - version='0.0.1', - description='Calculation and Visualization of Confidence Intervals and Effect Sizes for Python.', + version='0.0.2', + description='Data Analysis and Visualization using Bootstrapped Estimation.', packages=find_packages(), install_requires=installs, url='http://github.com/josesho/bootstrap_contrast',