• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Analyze and manipulate your Anki collection using pandas! 🌠🐼

Analyze and manipulate your Anki collection using pandas!

Documentation Status Gitter License PR welcome

pre-commit.ci status gh actions Coveralls CodeQL gitmoji Black Pypi status

πŸ“ Description

Anki is one of the most popular flashcard system for spaced repetition learning, pandas is the most popular python package for data analysis and manipulation. So what could be better than to bring both together?

With AnkiPandas you can use pandas to easily analyze or manipulate your Anki flashcards.

Features:

  • Select: Easily select arbitrary subsets of your cards, notes or reviews using pandas (one of many introductions, official documentation)
  • Visualize: Use pandas' powerful built in tools or switch to the even more versatile seaborn (statistical analysis) or matplotlib libraries
  • Manipulate & adding notes and cards: Apply fast bulk operations to the table (e.g. add tags, change decks, set field contents, suspend cards, ...) or iterate over the table and perform these manipulations step by step. This is still in alpha/beta! Proceed with care and please report bugs! (but ankipandas will always create a backup of your database before changing something).
  • Import and Export: Pandas can export to (and import from) csv, MS Excel, HTML, JSON, ... (io documentation)

Pros:

  • Easy installation: Install via python package manager (independent of your Anki installation)
  • Simple: Just one line of code to get started
  • Convenient: Bring together information about cards, notes, models, decks and more in just one table!
  • Fully documented: Documentation on readthedocs
  • Well tested: More than 100 unit tests to keep everything in check

Alternatives: If your main goal is to add new cards, models and more, you can also take a look at the genanki project.

πŸ“¦ Installation

AnkiPandas is available as pypi package and can be installed or upgrade with the python package manager:

pip3 install --user --upgrade ankipandas

Development installation

For the latest development version you can also work from a cloned version of this repository:

git clone https://github.com/klieret/ankipandas/
cd ankipandas
pip3 install --user --upgrade --editable .

If you want to help develop this package further, please also install the pre-commit hooks and use gitmoji:

pre-commit install
gitmoji -i

πŸ”₯ Let's get started!

Starting up is as easy as this:

from ankipandas import Collection

col = Collection()

And col.notes will be dataframe containing all notes, with additional methods that make many things easy. Similarly, you can access cards or reviews using col.cards or col.revs.

If called without any argument Collection() tries to find your Anki database by itself. However this might take some time. To make it easier, simply supply (part of) the path to the database and (if you have more than one user) your Anki user name, e.g. Collection(".local/share/Anki2/", user="User 1") on many Linux installations.

To get information about the interpretation of each column, use print(col.notes.help_cols()).

Take a look at the documentation to find out more about more about the available methods!

Some basic examples:

πŸ“ˆ Analysis

More examples: Analysis documentation, projects that use AnkiPandas.

Show a histogram of the number of reviews (repetitions) of each card for all decks:

col.cards.hist(column="creps", by="cdeck")

Show the number of leeches per deck as pie chart:

cards = col.cards.merge_notes()
selection = cards[cards.has_tag("leech")]
selection["cdeck"].value_counts().plot.pie()

Find all notes of model MnemoticModel with empty Mnemotic field:

notes = col.notes.fields_as_columns()
notes.query("model=='MnemoticModel' and 'Mnemotic'==''")

πŸ› οΈ Manipulations

Please be careful and test this well! Ankipandas will create a backup of your database before writing, so you can always restore the previous state. Please make sure that everything is working before continuing to use Anki normally!

Add the difficult-japanese and marked tag to all notes that contain the tags Japanese and leech:

notes = col.notes
selection = notes[notes.has_tags(["Japanese", "leech"])]
selection = selection.add_tag(["difficult-japanese", "marked"])
col.notes.update(selection)
col.write(modify=True)  # Overwrites your database after creating a backup!

Set the language field to English for all notes of model LanguageModel that are tagged with English:

notes = col.notes
selection = notes[notes.has_tag(["English"])].query("model=='LanguageModel'").copy()
selection.fields_as_columns(inplace=True)
selection["language"] = "English"
col.notes.update(selection)
col.write(modify=True)

Move all cards tagged leech to the deck Leeches Only:

cards = col.cards
selection = cards[cards.has_tag("leech")]
selection["cdeck"] = "Leeches Only"
col.cards.update(selection)
col.write(modify=True)

🐞 Troubleshooting

See the troubleshooting section in the documentation.

πŸ’– Contributing

Your help is greatly appreciated! Suggestions, bug reports and feature requests are best opened as github issues. You could also first discuss in the gitter community. If you want to code something yourself, you are very welcome to submit a pull request!

Bug reports and pull requests are credited with the help of the allcontributors bot.

πŸ“ƒ License & Disclaimer

This software is licenced under the MIT license and (despite best testing efforts) comes without any warranty. The logo is inspired by the Anki logo (license) and the logo of the pandas package (license2). This library and its author(s) are not affiliated/associated with the main Anki or pandas project in any way.

✨ Contributors

Thanks goes to these wonderful people (emoji key):

Blocked
Blocked

πŸ›
CalculusAce
CalculusAce

πŸ›
Francis Tseng
Francis Tseng

πŸ› πŸ’»
Keith Hughitt
Keith Hughitt

πŸ›
Miroslav Ε edivΓ½
Miroslav Ε edivΓ½

⚠️ πŸ’»
Nicholas Bollweg
Nicholas Bollweg

πŸ’»
Thomas Brownback
Thomas Brownback

πŸ›
eshrh
eshrh

πŸ“–
exc4l
exc4l

πŸ› πŸ’»
p4nix
p4nix

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

wandb-offline-sync-hook

A convenient way to trigger synchronizations to wandb / Weights & Biases if your compute nodes don't have internet!
Python
53
star
2

RandomFileTree

Create random file structures in python for testing purposes.
Python
31
star
3

everything-you-didnt-now-you-needed

Tips & Tricks for python, the command line, and more.
Python
29
star
4

verzettler

Non-linear, non-hierarchical knowledge management: Helper scripts for your Zettelkasten.
Python
18
star
5

icsc-paradigms-and-patterns

Slides and exercises for the iCSC lecture "Software Paradigms and Programming Patterns"
TeX
14
star
6

sunburst

Draw sunburst charts/hierarchical pie plots ("multi-level" pie plots of hierarchical data as e.g., in disk usage diagrams)
Python
13
star
7

anki-card-templates

Anki Cards for learning Japanese
HTML
8
star
8

collaborative-programming-github

Hands-on lecture material to explore collaborative programming with git and github
7
star
9

anki-merge-notes

Anki plugin to merge notes.
Python
6
star
10

anki-template-tester

Small tool to preview Anki templates.
Python
5
star
11

ray-tune-slurm-demo

Testing ray tune with slurm batch submission and optuna and wandb
Python
5
star
12

rtk-lookup

Looking up kanji from the book series "Remembering The Kanji" by James Heisig.
Python
4
star
13

HEPFittingTutorial

Some tutorial notebooks for fitting in Hight Energy Physics (alias particle physics).
4
star
14

anki-ignore-dupes

Addon to ignore duplicates in Anki based on the decks to which they belong.
Python
4
star
15

codas-hep-22-git-playground

Playground for participants of the CODAS HEP school 2022
Python
4
star
16

inspiderweb

Analyze papers referencing each other. Extracts information from inspirehep, then describes the network in the dot language. Result can be plotted by dot, neato & Co.
Python
3
star
17

ddss-llm-inference-platform

Dev repo for simple inference platform for princeton DDSS
Python
3
star
18

marp-cookiecutter

Cookiecutter template for my presentations with marp πŸ“πŸͺβœ‚οΈ
Makefile
2
star
19

simple-science-style

A simple style for matplotlib.
2
star
20

rtk-table-tools

Tables and posters and tools to generate them for Remembering the Kanji by James Heisig
Python
2
star
21

collab-git-playground-codas-hep-23

Playground repository for teaching collaborative programming using GitHub
2
star
22

collab-git-playground-codas-hep-24

Playground repository for teaching collaborative programming using GitHub
Python
1
star
23

readme-badge-extractor

Extract badges from github readmes and include them in html files.
Python
1
star
24

swe-agent-test-repo

Python
1
star
25

meetup-matcher

Match small groups of people for coffee, tea, or whatever
Python
1
star
26

obsidian-snippets

My snippets for obsidian
CSS
1
star
27

multi-gitter-failed-merge-handle-test-repo-2

Test repository for https://github.com/lindell/multi-gitter/issues/309
1
star
28

slidev-experiments

Experiments with slidev formatting
Vue
1
star
29

xonsh-cheatsheet

Minimal cheatsheet for xonsh
1
star
30

python-pre-commit-demo-tutorial

Try out useful pre-commits for python
Python
1
star
31

ray-tune-stoppers-contrib

Additional stoppers for ray tune
Python
1
star
32

anki-reset-fields

Adds a button to reset all fields in the editor window in Anki.
Python
1
star
33

anki-readings-audio

Add Kunyomi/Onyomi audio to kanji readings flashcards in Anki.
Python
1
star