Package: ankipandas
Analyze and manipulate your Anki collection using pandas!📝 DescriptionNoteThis package needs a new maintainer, as I currently do not have enough time to continue development
of this package. Writing modifications back into the Anki database is currently disabled,
in particular because of issue#137.
Please reach out to me if you are interested in getting involved!Ankiis one of the most popular flashcard
system for spaced repetition learning,pandasis the most popular python package
for data analysis and manipulation. So what could be better than to
bring both together?WithAnkiPandasyou can usepandasto easily analyze or manipulate
your Anki flashcards.Features:Select: Easily select arbitrary subsets of your cards, notes or
reviews usingpandas(one of many
introductions,official
documentation)Visualize: Use pandas' powerfulbuilt in
toolsor switch to the even more versatileseaborn(statistical analysis) ormatplotliblibrariesManipulate: 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 functionality is currently disabled until#137has been resolved! ⚠️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 startedConvenient: Bring together information aboutcards,notes,models,decksand more in
just one table!Fully documented: Documentation onreadthedocsWell tested: More than 100 unit tests to keep everything in
checkAlternatives: If your main goal is to add new cards, models and more,
you can also take a look at thegenankiproject.📦 InstallationAnkiPandasis available aspypi
packageand can be installed or
upgrade with thepython package
manager:pip3install--user--upgradeankipandasDevelopment installationFor the latest development version you can also work from a cloned
version of this repository:gitclonehttps://github.com/klieret/ankipandas/cdankipandas
pip3install--user--upgrade--editable.If you want to help develop this package further, please also install thepre-commithooks and usegitmoji:pre-commitinstall
gitmoji-i🔥 Let's get started!Starting up is as easy as this:fromankipandasimportCollectioncol=Collection()Andcol.noteswill be dataframe containing all notes, with additional
methods that make many things easy. Similarly, you can access cards or
reviews usingcol.cardsorcol.revs.If called without any argumentCollection()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, useprint(col.notes.help_cols()).Take a look at thedocumentationto find out more about more about the available methods!Some basic examples:📈 AnalysisMore examples:Analysis
documentation,projects that useAnkiPandas.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 modelMnemoticModelwith emptyMnemoticfield:notes=col.notes.fields_as_columns()notes.query("model=='MnemoticModel' and 'Mnemotic'==''")🛠️ ManipulationsWarningWriting the database has currently been disabled until#137has been resolved.
Help is much appreciated!WarningPlease 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 thedifficult-japaneseandmarkedtag to all notes that contain
the tagsJapaneseandleech:notes=col.notesselection=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 thelanguagefield toEnglishfor all notes of modelLanguageModelthat are tagged withEnglish:notes=col.notesselection=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 taggedleechto the deckLeeches Only:cards=col.cardsselection=cards[cards.has_tag("leech")]selection["cdeck"]="Leeches Only"col.cards.update(selection)col.write(modify=True)🐞 TroubleshootingSee thetroubleshooting section in the
documentation.💖 ContributingYour help is greatly appreciated! Suggestions, bug reports and feature
requests are best opened asgithub
issues. You could also
first discuss in thegitter
community. If you want to code
something yourself, you are very welcome to submit apull
request!Bug reports and pull requests are credited with the help of theallcontributors bot.📃 License & DisclaimerThis software is licenced under theMIT
licenseand (despite best testing efforts) comeswithout any warranty. The
logo is inspired by theAnki
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.✨ ContributorsThanks goes to these wonderful people (emoji key):Blocked🐛CalculusAce🐛Francis Tseng🐛💻Keith Hughitt🐛Miroslav Šedivý⚠️💻Nicholas Bollweg💻Thomas Brownback🐛eshrh📖exc4l🐛💻p4nix🐛This project follows theall-contributorsspecification. Contributions of any kind welcome!