Load your anki database as a pandas DataFrame with just one line of code!
Project description
NOTE: THIS PROJECT IS STILL AT AN EARLY DEVELOPMENT VERSION. TRY OUT WITH CARE.
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.
That means you can
Select: Easily select arbitrary subsets of your cards, notes or reviews (one of many introductions, official documentation)
Visualize: Use powerful built in tools or switch to the even more versatile seaborn (statistical analysis) or matplotlib
Manipulate: 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
Pros
Easy installation via python package manager (independent of your Anki installation)
Just one line of code to get started
Bring together information about cards, notes, models, decks and more in just one table!
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
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 .
Usage
Starting up is as easy as this:
from ankipandas import AnkiDataFrame
notes = AnkiDataFrame.notes()
And you have a dataframe containing all notes, with additional methods that make many things easy. Similarly, you can load notes or reviews using cards() or revs(). If called without any argument notes() (and friends) 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. AnkiDataFrame.cards(".local/share/Anki2/", user="User 1") on many Linux installations.
To get information about the interpretation of each column, use notes.help_cols().
Take a look at the documentation to find out more about more about the available methods!
Some basic examples:
Analysis
Show a histogram of the number of reviews (repetitions) of each card for all decks:
cards = AnkiDataFrame.cards()
cards.hist(column="creps", by="cdeck")
Show the number of leeches per deck as pie chart:
cards = AnkiDataFrame.cards()
selection = cards[cards.has_tag("leech")]
selection["cdeck"].value_counts().plot.pie()
Find all notes of model MnemoticModel with empty Mnemotic field:
notes = AnkiDataFrame.notes().fields_as_columns()
notes.query("model=='MnemoticModel' and 'Mnemotic'==''")
Manipulations
Add the difficult-japanese and marked tag to all notes that contain the tags Japanese and leech:
notes = AnkiDataFrame.notes()
selection = notes.has_tags(["Japanese", "leech"])
selection = selection.add_tag(["difficult-japanese", "marked"])
notes.update(selection)
notes.write() # 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 = AnkiDataFrame.notes()
selection = notes.has_tag(["English"]).query("model=='LanguageModel'").fields_as_columns()
selection["language"] = "English"
notes.update(selection).write()
Move all cards tagged leech to the deck Leeches Only:
cards = AnkiDataFrame.cards().merge_notes()
selection = cards.has_tag("leech")
selection["cdeck"] = "Leeches Only"
cards.update(selection).write()
Troubleshooting
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!
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ankipandas-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f5dd80d4e621d3c9e1d6b373dbb59e1c90782b18f1c05cae710374df1972028 |
|
MD5 | 41bf5b99c3c2010e377791ad3d99f46a |
|
BLAKE2b-256 | 6c01a0b8ea19ff00c94fd075e5de2b87229b39e32ec94cb54f1b3a01cb6b62ea |