Skip to main content

Faster and more Insightful analysis of survey results

This package lets you apply advanced Natural Language Processing (NLP) and Machine Learning functions on survey results directly within a dataframe.

It fills a gap where many NLP packages (like spacy, genism, sentence_transformers) are not designed for data in a spreadsheet (and therefore imported into a dataframe), and many of the people who are tasked with analysing survey results are often not data scientists.

For example, to extract the sentiment you can just type:

df.extract_sentiment(input_column="survey-comments")

It will abstract away a lot of the data transformation pipeline to give you useful functionality with minimal code.

Installation

pip install pandas-survey-toolkit           # Likert clustering + text preprocessing (torch-free)
pip install "pandas-survey-toolkit[nlp]"    # + free-text comment tooling (sentence embeddings, spaCy, transformer sentiment)

The core install is lightweight and does not pull in torch/spacy, so clustering Likert questions/respondents works without the heavy deep-learning stack. Install the [nlp] extra when you need free-text comment embeddings, spaCy pipelines, or transformer sentiment.

Examples

See ReadTheDocs for simple example notebooks. There are more detailed notebooks in the repo under notebooks/

Functionality

Clustering comments

It will group similar free-text comments together and assign a cluster ID. This is a useful step prior to any qualitative analysis.

Sentiment Analysis

It will measure the sentiment in terms or postive / neutral / negative and assign a score for each of those parts, picking the highest scoring as the most likely overall sentiment.

Topic analysis

Involves TFIDF and word co-occurence to gain some high level insights into the likely topics

Clustering a Likert survey (respondents and questions)

For strongly disagree ... neutral ... strongly agree responses, the toolkit clusters both axes purely from the data (no NLP on the question text):

Responses are encoded on a simple 3-point scale (−1 / 0 / +1) and grouped with cosine distance, which compares the direction of people's opinions — so respondents who agree with everything and respondents who disagree with everything separate cleanly.

  • Respondents — group people who answer along similar lines:
    • df.cluster_respondents(method="auto") — picks the engine by survey size (below). This is the one to reach for.
    • df.cluster_respondents_cosine(...) — cosine distance + hierarchical (dendrogram) clustering. Best for small/medium surveys.
    • df.cluster_respondents_umap(...) — UMAP + HDBSCAN. Scales to very large surveys (many respondents).
  • Questions — group questions that get answered similarly:
    • df.cluster_questions(...) — returns a pd.Series (question → cluster id) you can inspect or save to CSV. (In 2.0 this clusters questions; in 1.x it was a deprecated alias that clustered respondents.)
  • Everything at once — df.cluster_survey(likert_cols) clusters respondents and questions and orders both axes so the plots below "just work".

See docs/source/clustering_methods_comparison.md for the maths, the distance-threshold rule of thumb, and small-survey advice.

Visualisation

  • cluster_heatmap_plot(...) — Altair heatmap of sentiment per respondent-cluster × question, with a cluster-size bar chart. Best for many respondents / few clusters; questions auto-ordered by their cluster.
  • survey_clustermap(...) — seaborn biclustered clustermap of individual respondents × questions with marginal dendrograms. Best for few respondents, where you can see everyone.
  • plot_respondent_dendrogram(...) — the respondent dendrogram from cosine clustering.

Setup

If sentence transformers throws dll errors: https://stackoverflow.com/questions/78484297/c-torch-lib-fbgemm-dll-or-one-of-its-dependencies/78794748#78794748

Metadata

Release files for pandas-survey-toolkit 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pandas-survey-toolkit 2.0.1
File Size Uploaded Provenance Actions
pandas_survey_toolkit-2.0.1.tar.gz 620.0 kB Without provenance Details for pandas_survey_toolkit-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pandas-survey-toolkit 2.0.1
File Interpreter ABI Platform Actions
pandas_survey_toolkit-2.0.1-py3-none-any.whl Python 3 none any Details for pandas_survey_toolkit-2.0.1-py3-none-any.whl

Total release size: 653.3 kB

Release files / pandas_survey_toolkit-2.0.1.tar.gz

Download URL pandas_survey_toolkit-2.0.1.tar.gz
Size 620.0 kB
Tags Source
SHA-256 checksum
How to use checksums
556cd5ffdb7e0e51b41d1347453f195492e9b5941b678c599b64302c7cccb464
BLAKE2b-256 checksum
How to use checksums
12b4416f1866e317681fd1d10c2a7a95985f3fe5fb2b040ad5b96df0f7ea5086
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / pandas_survey_toolkit-2.0.1-py3-none-any.whl

Download URL pandas_survey_toolkit-2.0.1-py3-none-any.whl
Size 33.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1ee11abf60421969e65d463b3c98829ea837e89175d82b5c09698e5470abd0c
BLAKE2b-256 checksum
How to use checksums
2b26c0ceb092f893c1d581b0d996ecb98d5690f5b500fd2ab2e2cdc62282d849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for pandas-survey-toolkit 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page