kandi background

seaborn | Statistical data visualization using matplotlib | Data Visualization library

Download this library from

kandi X-RAY | seaborn Summary

seaborn is a Python library typically used in Analytics, Data Visualization, Pandas applications. seaborn has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub.
Statistical data visualization in Python

kandi-support Support

  • seaborn has a highly active ecosystem.
  • It has 9320 star(s) with 1582 fork(s). There are 248 watchers for this library.
  • There were 2 major release(s) in the last 12 months.
  • There are 105 open issues and 1892 have been closed. On average issues are closed in 66 days. There are 11 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of seaborn is v0.11.2

quality kandi Quality

  • seaborn has 0 bugs and 0 code smells.

securitySecurity

  • seaborn has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • seaborn code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license License

  • seaborn is licensed under the BSD-3-Clause License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

buildReuse

  • seaborn releases are available to install and integrate.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • seaborn saves you 13118 person hours of effort in developing the same functionality from scratch.
  • It has 26955 lines of code, 1355 functions and 102 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
Top functions reviewed by kandi - BETA

kandi has reviewed seaborn and discovered the below as its top functions. This is intended to give you an instant insight into seaborn implemented functionality, and help decide if they suit your requirements.

  • Plot a univariate histogram .
  • Plot a scatter plot .
  • Plot a distribution plot .
  • Plot a heat map .
  • Plots a ~astropy . distribution .
  • Plot a cluster map .
  • Draw violin bins .
  • Plot a scatter plot .
  • Plot a kernel density plot .
  • Plot a matplotlib figure .

seaborn Key Features

Statistical data visualization in Python

seaborn Examples and Code Snippets

  • default
  • Getting Error 0 when plotting boxplot of a filtered dataset
  • Resize axes of top and right joint marginal plots to match central plot with matplotlib
  • How to paste an Excel chart into PowerPoint placeholder using Python?
  • How to install local package with conda
  • How to add median and IQR to seaborn violinplot
  • Pandas agg define metric based on data type
  • Adding columns & values per group occurrence in pandas after filtering
  • Matplotlib scatter plot marker type from dictionary
  • Google Colab ModuleNotFoundError: No module named 'sklearn.externals.joblib'
  • Seaborn heatmap change date frequency of yticks

default

seaborn: statistical data visualization
=======================================

[![PyPI Version](https://img.shields.io/pypi/v/seaborn.svg)](https://pypi.org/project/seaborn/)
[![License](https://img.shields.io/pypi/l/seaborn.svg)](https://github.com/mwaskom/seaborn/blob/master/LICENSE)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.03021/status.svg)](https://doi.org/10.21105/joss.03021)
[![Tests](https://github.com/mwaskom/seaborn/workflows/CI/badge.svg)](https://github.com/mwaskom/seaborn/actions)
[![Code Coverage](https://codecov.io/gh/mwaskom/seaborn/branch/master/graph/badge.svg)](https://codecov.io/gh/mwaskom/seaborn)

Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics.


Documentation
-------------

Online documentation is available at [seaborn.pydata.org](https://seaborn.pydata.org).

The docs include a [tutorial](https://seaborn.pydata.org/tutorial.html), [example gallery](https://seaborn.pydata.org/examples/index.html), [API reference](https://seaborn.pydata.org/api.html), and other useful information.

To build the documentation locally, please refer to [`doc/README.md`](doc/README.md).

There is also a [FAQ](https://github.com/mwaskom/seaborn/wiki/Frequently-Asked-Questions-(FAQs)) page, currently hosted on GitHub.

Dependencies
------------

Seaborn supports Python 3.7+ and no longer supports Python 2.

Installation requires [numpy](https://numpy.org/), [pandas](https://pandas.pydata.org/), and [matplotlib](https://matplotlib.org/). Some functions will optionally use [scipy](https://www.scipy.org/) and/or [statsmodels](https://www.statsmodels.org/) if they are available.


Installation
------------

The latest stable release (and required dependencies) can be installed from PyPI:

    pip install seaborn

It is also possible to include optional dependencies (only relevant for v0.12+):

    pip install seaborn[all]

Seaborn can also be installed with conda:

    conda install seaborn

Note that the main anaconda repository typically lags PyPI in adding new releases, but conda-forge (`-c conda-forge`) typically updates quickly.

Citing
------

A paper describing seaborn has been published in the [Journal of Open Source Software](https://joss.theoj.org/papers/10.21105/joss.03021). The paper provides an introduction to the key features of the library, and it can be used as a citation if seaborn proves integral to a scientific publication.

Testing
-------

Testing seaborn requires installing additional packages listed in `ci/utils.txt`.

To test the code, run `make test` in the source directory. This will exercise both the unit tests and docstring examples (using [pytest](https://docs.pytest.org/)) and generate a coverage report.

The doctests require a network connection (unless all example datasets are cached), but the unit tests can be run offline with `make unittests`.

Code style is enforced with `flake8` using the settings in the [`setup.cfg`](./setup.cfg) file. Run `make lint` to check.

Development
-----------

Seaborn development takes place on Github: https://github.com/mwaskom/seaborn

Please submit bugs that you encounter to the [issue tracker](https://github.com/mwaskom/seaborn/issues) with a reproducible example demonstrating the problem. Questions about usage are more at home on StackOverflow, where there is a [seaborn tag](https://stackoverflow.com/questions/tagged/seaborn).

Community Discussions

Trending Discussions on seaborn
  • Getting Error 0 when plotting boxplot of a filtered dataset
  • Resize axes of top and right joint marginal plots to match central plot with matplotlib
  • How to paste an Excel chart into PowerPoint placeholder using Python?
  • How to install local package with conda
  • How to add median and IQR to seaborn violinplot
  • Can't deploy streamlit app on share.streamlit.io
  • Pandas agg define metric based on data type
  • Heatmap error :'NoneType' object is not callable when using with dataframe
  • Adding columns & values per group occurrence in pandas after filtering
  • Matplotlib scatter plot marker type from dictionary
Trending Discussions on seaborn

QUESTION

Getting Error 0 when plotting boxplot of a filtered dataset

Asked 2022-Mar-11 at 15:48

I am working on the Kaggle: Abalone dataset and I am facing a weird problem when plotting a boxplot.

import pandas as pd
import seaborn as sns

df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data', header=None)
df.columns = ['sex', 'Length', 'Diameter', 'Height', 'Whole weight', 'Shucked weight', 'Viscera weight', 'Shell weight', 'rings']

If a run:

plt.figure(figsize=(16,6))
plt.subplot(121)
sns.boxplot(data=df['rings'])

working perfectly!

If I filter the dataset by sex like this:

df_f = df[df['sex']=='F']
df_m = df[df['sex']=='M']
df_i = df[df['sex']=='I']

df_f = (1307,9), df_m=(1528,9) and df_i=(1342,9)

And I run:

plt.figure(figsize=(16,6))
plt.subplot(121)
sns.boxplot(data=df_m['rings'])

working perfectly!

But if I run the code above for df_f and df_i datasets I get an error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   3360             try:
-> 3361                 return self._engine.get_loc(casted_key)
   3362             except KeyError as err:

~/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

~/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()

KeyError: 0

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_434828/3363262611.py in <module>
----> 1 sns.boxplot(data=df_f['Rings'])

~/anaconda3/lib/python3.9/site-packages/seaborn/_decorators.py in inner_f(*args, **kwargs)
     44             )
     45         kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46         return f(**kwargs)
     47     return inner_f
     48 

~/anaconda3/lib/python3.9/site-packages/seaborn/categorical.py in boxplot(x, y, hue, data, order, hue_order, orient, color, palette, saturation, width, dodge, fliersize, linewidth, whis, ax, **kwargs)
   2241 ):
   2242 
-> 2243     plotter = _BoxPlotter(x, y, hue, data, order, hue_order,
   2244                           orient, color, palette, saturation,
   2245                           width, dodge, fliersize, linewidth)

~/anaconda3/lib/python3.9/site-packages/seaborn/categorical.py in __init__(self, x, y, hue, data, order, hue_order, orient, color, palette, saturation, width, dodge, fliersize, linewidth)
    404                  width, dodge, fliersize, linewidth):
    405 
--> 406         self.establish_variables(x, y, hue, data, orient, order, hue_order)
    407         self.establish_colors(color, palette, saturation)
    408 

~/anaconda3/lib/python3.9/site-packages/seaborn/categorical.py in establish_variables(self, x, y, hue, data, orient, order, hue_order, units)
     96                 if hasattr(data, "shape"):
     97                     if len(data.shape) == 1:
---> 98                         if np.isscalar(data[0]):
     99                             plot_data = [data]
    100                         else:

~/anaconda3/lib/python3.9/site-packages/pandas/core/series.py in __getitem__(self, key)
    940 
    941         elif key_is_scalar:
--> 942             return self._get_value(key)
    943 
    944         if is_hashable(key):

~/anaconda3/lib/python3.9/site-packages/pandas/core/series.py in _get_value(self, label, takeable)
   1049 
   1050         # Similar to Index.get_value, but we do not fall back to positional
-> 1051         loc = self.index.get_loc(label)
   1052         return self.index._get_values_for_loc(self, loc, label)
   1053 

~/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   3361                 return self._engine.get_loc(casted_key)
   3362             except KeyError as err:
-> 3363                 raise KeyError(key) from err
   3364 
   3365         if is_scalar(key) and isna(key) and not self.hasnans:

KeyError: 0

There's no missing values, all values are int.

What am I missing here?

ANSWER

Answered 2022-Mar-10 at 10:38

If you want a box plot per value of a categorical column I suggest:

sns.boxplot(data=df, x='rings', y='sex')

Source https://stackoverflow.com/questions/71422431

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install seaborn

You can download it from GitHub.
You can use seaborn like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Build your Application

Share this kandi XRay Report