Created
June 17, 2021 20:59
-
-
Save eshrh/715482a3ff02723a9225e8f040069059 to your computer and use it in GitHub Desktop.
Add pitch numbers to yomichan cards using ankipandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "ee0e70ec", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import ankipandas as ankipd\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "4899b040", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"\u001b[32mINFO: Searching for database. This might take some time. You can speed this up by specifying a search path or directly entering the path to your database.\u001b[0m\n", | |
"\u001b[33mWARNING: The search will stop at the first hit, so please verify that the result is correct (for example in case there might be more than one Anki installation)\u001b[0m\n" | |
] | |
} | |
], | |
"source": [ | |
"from ankipandas import Collection\n", | |
"col = Collection()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "343466fc", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"notes = col.notes" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "d2625843", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"ymch = notes[notes.has_tag([\"yomichan\"])].copy()\n", | |
"ymch.fields_as_columns(inplace=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "3ab4e71e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"<ipython-input-6-0bc36e07eba2>:1: ParserWarning: Falling back to the 'python' engine because the separator encoded in utf-8 is > 1 char long, and the 'c' engine does not support such separators; you can avoid this warning by specifying engine='python'.\n", | |
" pitchdb = pd.read_csv(\"wadoku_pitchdb.csv\",sep=\"␞\",header=None)\n" | |
] | |
} | |
], | |
"source": [ | |
"pitchdb = pd.read_csv(\"wadoku_pitchdb.csv\",sep=\"␞\",header=None)\n", | |
"pitchdb.columns = [\"word\",\"kana\",\"garb\",\"pitch\",\"lh\"]\n", | |
"pitchdb = pitchdb[[\"kana\",\"pitch\"]]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "941d3f4a", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"pitchdb = pitchdb.drop_duplicates(subset=\"kana\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "1c033c6b", | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>nguid</th>\n", | |
" <th>nmod</th>\n", | |
" <th>nusn</th>\n", | |
" <th>ntags</th>\n", | |
" <th>nmodel</th>\n", | |
" <th>nfld_sentence</th>\n", | |
" <th>nfld_Expression</th>\n", | |
" <th>nfld_furigana</th>\n", | |
" <th>nfld_reading</th>\n", | |
" <th>nfld_meaning</th>\n", | |
" <th>nfld_image</th>\n", | |
" <th>nfld_audio</th>\n", | |
" <th>nfld_pitch_position</th>\n", | |
" <th>nfld_pitch</th>\n", | |
" <th>nfld_cloze_prefix</th>\n", | |
" <th>nfld_cloze_body</th>\n", | |
" <th>nfld_cloze_suffix</th>\n", | |
" <th>nfld_frequency</th>\n", | |
" <th>kana</th>\n", | |
" <th>pitch</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>xZy/=1+nZ$</td>\n", | |
" <td>1615431247</td>\n", | |
" <td>1205</td>\n", | |
" <td>[japanese_seen, yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>「風」というものは別にどこで買うわけでもなく、そこら中に溢れているものです。</td>\n", | |
" <td>溢れる</td>\n", | |
" <td><ruby>溢<rt>あふ</rt></ruby>れる</td>\n", | |
" <td>あふれる</td>\n", | |
" <td><div style=\"text-align: left;\"><i>(v1, vi, uk,...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td><svg xmlns=\"http://www.w3.org/2000/svg\" viewBo...</td>\n", | |
" <td><span><span style=\"display:inline-block;positi...</td>\n", | |
" <td>「風」というものは別にどこで買うわけでもなく、そこら中に</td>\n", | |
" <td>溢れている</td>\n", | |
" <td>ものです。</td>\n", | |
" <td></td>\n", | |
" <td>あふれる</td>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>A&`7C=+p3z</td>\n", | |
" <td>1615431247</td>\n", | |
" <td>1205</td>\n", | |
" <td>[japanese_seen, yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>自然に生きる中にも、心惹かれるものが世界には溢れている。</td>\n", | |
" <td>心惹かれる</td>\n", | |
" <td><ruby>心惹<rt>こころひ</rt></ruby>かれる</td>\n", | |
" <td>こころひかれる</td>\n", | |
" <td><div style=\"text-align: left;\"><i>(v1, JMdict ...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>No pitch accent data</td>\n", | |
" <td>No pitch accent data</td>\n", | |
" <td>自然に生きる中にも、</td>\n", | |
" <td>心惹かれる</td>\n", | |
" <td>ものが世界には溢れている。</td>\n", | |
" <td></td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>JLJ>A(zMu4</td>\n", | |
" <td>1615431247</td>\n", | |
" <td>1205</td>\n", | |
" <td>[japanese_seen, yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>ここでの美しい自然の表現は、明確に何かを比喩しているだとか、実は全く別のものを歌っているだと...</td>\n", | |
" <td>比喩</td>\n", | |
" <td><ruby>比喩<rt>ひゆ</rt></ruby></td>\n", | |
" <td>ひゆ</td>\n", | |
" <td><div style=\"text-align: left;\"><i>(n, JMdict (...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td><svg xmlns=\"http://www.w3.org/2000/svg\" viewBo...</td>\n", | |
" <td><span><span style=\"display:inline-block;positi...</td>\n", | |
" <td>ここでの美しい自然の表現は、明確に何かを</td>\n", | |
" <td>比喩</td>\n", | |
" <td>しているだとか、実は全く別のものを歌っているだとか</td>\n", | |
" <td></td>\n", | |
" <td>ひゆ</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>fyV4i>U_?S</td>\n", | |
" <td>1615431247</td>\n", | |
" <td>1205</td>\n", | |
" <td>[japanese_seen, yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>古代語発音の信憑性がかなり低くなった。</td>\n", | |
" <td>信憑性</td>\n", | |
" <td><ruby>信憑性<rt>しんぴょうせい</rt></ruby></td>\n", | |
" <td>しんぴょうせい</td>\n", | |
" <td><div style=\"text-align: left;\"><i>(n, JMdict (...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td><svg xmlns=\"http://www.w3.org/2000/svg\" viewBo...</td>\n", | |
" <td><span><span style=\"display:inline-block;positi...</td>\n", | |
" <td>古代語発音の</td>\n", | |
" <td>信憑性</td>\n", | |
" <td>がかなり低くなった。</td>\n", | |
" <td></td>\n", | |
" <td>しんぴょうせい</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>p]$DB0qqrv</td>\n", | |
" <td>1615431247</td>\n", | |
" <td>1205</td>\n", | |
" <td>[japanese_seen, yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>古代日本語の訛りがありますね</td>\n", | |
" <td>訛り</td>\n", | |
" <td><ruby>訛<rt>なま</rt></ruby>り</td>\n", | |
" <td>なまり</td>\n", | |
" <td><div style=\"text-align: left;\"><ol><li><i>(n, ...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td><ol><li><svg xmlns=\"http://www.w3.org/2000/svg...</td>\n", | |
" <td><ol><li><span><span style=\"display:inline-bloc...</td>\n", | |
" <td>古代日本語の</td>\n", | |
" <td>訛り</td>\n", | |
" <td>がありますね</td>\n", | |
" <td></td>\n", | |
" <td>なまり</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>...</th>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3105</th>\n", | |
" <td>M}-YC>GeQK</td>\n", | |
" <td>1623884151</td>\n", | |
" <td>1638</td>\n", | |
" <td>[yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>その星屑めいた光は、まるで天から降る億千の金貨に思えた。</td>\n", | |
" <td>星屑</td>\n", | |
" <td><ruby>星屑<rt>ほしくず</rt></ruby></td>\n", | |
" <td>ほしくず</td>\n", | |
" <td><div style=\"text-align: left;\"><ol><li>stardus...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td><svg xmlns=\"http://www.w3.org/2000/svg\" viewBo...</td>\n", | |
" <td><span><span style=\"display:inline-block;positi...</td>\n", | |
" <td>その</td>\n", | |
" <td>星屑</td>\n", | |
" <td>めいた光は、まるで天から降る億千の金貨に思えた。</td>\n", | |
" <td><ul style=\"text-align: left;\"><li>Narou Freq: ...</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3106</th>\n", | |
" <td>M>DbWHIuTB</td>\n", | |
" <td>1623884294</td>\n", | |
" <td>1638</td>\n", | |
" <td>[yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>世界の終わりが可視化されるのなら、例えばこうした穏やかなものなのだと思う。</td>\n", | |
" <td>可視化</td>\n", | |
" <td><ruby>可視化<rt>かしか</rt></ruby></td>\n", | |
" <td>かしか</td>\n", | |
" <td><div style=\"text-align: left;\"><ol><li>visuali...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>世界の終わりが</td>\n", | |
" <td>可視化</td>\n", | |
" <td>されるのなら、例えばこうした穏やかなものなのだと思う。</td>\n", | |
" <td><ul style=\"text-align: left;\"><li>Anime &amp; ...</td>\n", | |
" <td>かしか</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3107</th>\n", | |
" <td>p$>18K&A9-</td>\n", | |
" <td>1623884343</td>\n", | |
" <td>1638</td>\n", | |
" <td>[yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>また見惚れてるんですか?</td>\n", | |
" <td>見惚れる</td>\n", | |
" <td><ruby>見惚<rt>みと</rt></ruby>れる</td>\n", | |
" <td>みとれる</td>\n", | |
" <td><div style=\"text-align: left;\"><ol><li>to be f...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td><svg xmlns=\"http://www.w3.org/2000/svg\" viewBo...</td>\n", | |
" <td><span><span style=\"display:inline-block;positi...</td>\n", | |
" <td>また</td>\n", | |
" <td>見惚れてる</td>\n", | |
" <td>んですか?</td>\n", | |
" <td><ul style=\"text-align: left;\"><li>Narou Freq: ...</td>\n", | |
" <td>みとれる</td>\n", | |
" <td>0,3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3108</th>\n", | |
" <td>tS,Z7us^Jb</td>\n", | |
" <td>1623890602</td>\n", | |
" <td>1638</td>\n", | |
" <td>[yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>ほとん殆どないShow inflections</td>\n", | |
" <td>殆どない</td>\n", | |
" <td><ruby>殆<rt>ほとん</rt></ruby>どない</td>\n", | |
" <td>ほとんどない</td>\n", | |
" <td><div style=\"text-align: left;\"><ol><li>almost ...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>ほとん</td>\n", | |
" <td>殆どない</td>\n", | |
" <td>Show inflections</td>\n", | |
" <td></td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3109</th>\n", | |
" <td>N$661^C*V<</td>\n", | |
" <td>1623939053</td>\n", | |
" <td>0</td>\n", | |
" <td>[yomichan]</td>\n", | |
" <td>yomichan Japanese</td>\n", | |
" <td>いい、なんでもない</td>\n", | |
" <td>何でもない</td>\n", | |
" <td><ruby>何<rt>なん</rt></ruby>でもない</td>\n", | |
" <td>なんでもない</td>\n", | |
" <td><div style=\"text-align: left;\"><ol><li>easy | ...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td><span>[5]</span></td>\n", | |
" <td><span><span style=\"display:inline-block;positi...</td>\n", | |
" <td>いい、</td>\n", | |
" <td>なんでもない</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>なんでもない</td>\n", | |
" <td>5</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>3110 rows × 20 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" nguid nmod nusn ntags \\\n", | |
"0 xZy/=1+nZ$ 1615431247 1205 [japanese_seen, yomichan] \n", | |
"1 A&`7C=+p3z 1615431247 1205 [japanese_seen, yomichan] \n", | |
"2 JLJ>A(zMu4 1615431247 1205 [japanese_seen, yomichan] \n", | |
"3 fyV4i>U_?S 1615431247 1205 [japanese_seen, yomichan] \n", | |
"4 p]$DB0qqrv 1615431247 1205 [japanese_seen, yomichan] \n", | |
"... ... ... ... ... \n", | |
"3105 M}-YC>GeQK 1623884151 1638 [yomichan] \n", | |
"3106 M>DbWHIuTB 1623884294 1638 [yomichan] \n", | |
"3107 p$>18K&A9- 1623884343 1638 [yomichan] \n", | |
"3108 tS,Z7us^Jb 1623890602 1638 [yomichan] \n", | |
"3109 N$661^C*V< 1623939053 0 [yomichan] \n", | |
"\n", | |
" nmodel nfld_sentence \\\n", | |
"0 yomichan Japanese 「風」というものは別にどこで買うわけでもなく、そこら中に溢れているものです。 \n", | |
"1 yomichan Japanese 自然に生きる中にも、心惹かれるものが世界には溢れている。 \n", | |
"2 yomichan Japanese ここでの美しい自然の表現は、明確に何かを比喩しているだとか、実は全く別のものを歌っているだと... \n", | |
"3 yomichan Japanese 古代語発音の信憑性がかなり低くなった。 \n", | |
"4 yomichan Japanese 古代日本語の訛りがありますね \n", | |
"... ... ... \n", | |
"3105 yomichan Japanese その星屑めいた光は、まるで天から降る億千の金貨に思えた。 \n", | |
"3106 yomichan Japanese 世界の終わりが可視化されるのなら、例えばこうした穏やかなものなのだと思う。 \n", | |
"3107 yomichan Japanese また見惚れてるんですか? \n", | |
"3108 yomichan Japanese ほとん殆どないShow inflections \n", | |
"3109 yomichan Japanese いい、なんでもない \n", | |
"\n", | |
" nfld_Expression nfld_furigana nfld_reading \\\n", | |
"0 溢れる <ruby>溢<rt>あふ</rt></ruby>れる あふれる \n", | |
"1 心惹かれる <ruby>心惹<rt>こころひ</rt></ruby>かれる こころひかれる \n", | |
"2 比喩 <ruby>比喩<rt>ひゆ</rt></ruby> ひゆ \n", | |
"3 信憑性 <ruby>信憑性<rt>しんぴょうせい</rt></ruby> しんぴょうせい \n", | |
"4 訛り <ruby>訛<rt>なま</rt></ruby>り なまり \n", | |
"... ... ... ... \n", | |
"3105 星屑 <ruby>星屑<rt>ほしくず</rt></ruby> ほしくず \n", | |
"3106 可視化 <ruby>可視化<rt>かしか</rt></ruby> かしか \n", | |
"3107 見惚れる <ruby>見惚<rt>みと</rt></ruby>れる みとれる \n", | |
"3108 殆どない <ruby>殆<rt>ほとん</rt></ruby>どない ほとんどない \n", | |
"3109 何でもない <ruby>何<rt>なん</rt></ruby>でもない なんでもない \n", | |
"\n", | |
" nfld_meaning nfld_image nfld_audio \\\n", | |
"0 <div style=\"text-align: left;\"><i>(v1, vi, uk,... \n", | |
"1 <div style=\"text-align: left;\"><i>(v1, JMdict ... \n", | |
"2 <div style=\"text-align: left;\"><i>(n, JMdict (... \n", | |
"3 <div style=\"text-align: left;\"><i>(n, JMdict (... \n", | |
"4 <div style=\"text-align: left;\"><ol><li><i>(n, ... \n", | |
"... ... ... ... \n", | |
"3105 <div style=\"text-align: left;\"><ol><li>stardus... \n", | |
"3106 <div style=\"text-align: left;\"><ol><li>visuali... \n", | |
"3107 <div style=\"text-align: left;\"><ol><li>to be f... \n", | |
"3108 <div style=\"text-align: left;\"><ol><li>almost ... \n", | |
"3109 <div style=\"text-align: left;\"><ol><li>easy | ... \n", | |
"\n", | |
" nfld_pitch_position \\\n", | |
"0 <svg xmlns=\"http://www.w3.org/2000/svg\" viewBo... \n", | |
"1 No pitch accent data \n", | |
"2 <svg xmlns=\"http://www.w3.org/2000/svg\" viewBo... \n", | |
"3 <svg xmlns=\"http://www.w3.org/2000/svg\" viewBo... \n", | |
"4 <ol><li><svg xmlns=\"http://www.w3.org/2000/svg... \n", | |
"... ... \n", | |
"3105 <svg xmlns=\"http://www.w3.org/2000/svg\" viewBo... \n", | |
"3106 \n", | |
"3107 <svg xmlns=\"http://www.w3.org/2000/svg\" viewBo... \n", | |
"3108 \n", | |
"3109 <span>[5]</span> \n", | |
"\n", | |
" nfld_pitch \\\n", | |
"0 <span><span style=\"display:inline-block;positi... \n", | |
"1 No pitch accent data \n", | |
"2 <span><span style=\"display:inline-block;positi... \n", | |
"3 <span><span style=\"display:inline-block;positi... \n", | |
"4 <ol><li><span><span style=\"display:inline-bloc... \n", | |
"... ... \n", | |
"3105 <span><span style=\"display:inline-block;positi... \n", | |
"3106 \n", | |
"3107 <span><span style=\"display:inline-block;positi... \n", | |
"3108 \n", | |
"3109 <span><span style=\"display:inline-block;positi... \n", | |
"\n", | |
" nfld_cloze_prefix nfld_cloze_body \\\n", | |
"0 「風」というものは別にどこで買うわけでもなく、そこら中に 溢れている \n", | |
"1 自然に生きる中にも、 心惹かれる \n", | |
"2 ここでの美しい自然の表現は、明確に何かを 比喩 \n", | |
"3 古代語発音の 信憑性 \n", | |
"4 古代日本語の 訛り \n", | |
"... ... ... \n", | |
"3105 その 星屑 \n", | |
"3106 世界の終わりが 可視化 \n", | |
"3107 また 見惚れてる \n", | |
"3108 ほとん 殆どない \n", | |
"3109 いい、 なんでもない \n", | |
"\n", | |
" nfld_cloze_suffix \\\n", | |
"0 ものです。 \n", | |
"1 ものが世界には溢れている。 \n", | |
"2 しているだとか、実は全く別のものを歌っているだとか \n", | |
"3 がかなり低くなった。 \n", | |
"4 がありますね \n", | |
"... ... \n", | |
"3105 めいた光は、まるで天から降る億千の金貨に思えた。 \n", | |
"3106 されるのなら、例えばこうした穏やかなものなのだと思う。 \n", | |
"3107 んですか? \n", | |
"3108 Show inflections \n", | |
"3109 \n", | |
"\n", | |
" nfld_frequency kana pitch \n", | |
"0 あふれる 3 \n", | |
"1 NaN NaN \n", | |
"2 ひゆ 1 \n", | |
"3 しんぴょうせい 0 \n", | |
"4 なまり 0 \n", | |
"... ... ... ... \n", | |
"3105 <ul style=\"text-align: left;\"><li>Narou Freq: ... NaN NaN \n", | |
"3106 <ul style=\"text-align: left;\"><li>Anime & ... かしか 0 \n", | |
"3107 <ul style=\"text-align: left;\"><li>Narou Freq: ... みとれる 0,3 \n", | |
"3108 NaN NaN \n", | |
"3109 なんでもない 5 \n", | |
"\n", | |
"[3110 rows x 20 columns]" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"merged = pd.merge(ymch,pitchdb,left_on=\"nfld_reading\",right_on=\"kana\",how=\"left\")\n", | |
"merged" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "9fffef56", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"merged.drop(\"kana\",1,inplace=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "df9d3620", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"\n", | |
"merged[\"pitch\"].replace(np.NaN, \"Not Found\",inplace=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "839e5cbb", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "664fd9b2", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0 [3]\n", | |
"1 [Not Found]\n", | |
"2 [1]\n", | |
"3 [0]\n", | |
"4 [0]\n", | |
" ... \n", | |
"3105 [Not Found]\n", | |
"3106 [0]\n", | |
"3107 [0]\n", | |
"3108 [Not Found]\n", | |
"3109 [5]\n", | |
"Name: pitch, Length: 3110, dtype: object" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"def formatter(s): \n", | |
" if \",\" in s:\n", | |
" s = s.split(\",\")[0]\n", | |
" return \"[\"+s+\"]\"\n", | |
"\n", | |
"merged[\"pitch\"].map(formatter)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "936dacd9", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"merged[\"nfld_pitch_position\"] = merged[\"pitch\"].map(formatter)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"id": "db21834d", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"merged.drop(\"pitch\",1,inplace=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "efaa4f74", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"id": "2dc477a9", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"ymch[\"nfld_pitch_position\"] = merged[\"nfld_pitch_position\"].values" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"id": "1f3b1e72", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"======== notes ========\n", | |
"Total rows: 14181\n", | |
"Compared to original version:\n", | |
"Modified rows: 3110\n", | |
"Added rows: 0\n", | |
"Deleted rows: 0\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/home/esrh/.local/lib/python3.9/site-packages/ankipandas/ankidf.py:839: FutureWarning: Index.__and__ operating as a set operation is deprecated, in the future this will be a logical operation matching Series.__and__. Use index.intersection(other) instead\n", | |
" inters = set(self_sf.index & other_nids)\n" | |
] | |
} | |
], | |
"source": [ | |
"col.notes.update(ymch.fields_as_list())\n", | |
"col.summarize_changes()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"id": "7ab453cb", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/home/esrh/.local/lib/python3.9/site-packages/ankipandas/ankidf.py:839: FutureWarning: Index.__and__ operating as a set operation is deprecated, in the future this will be a logical operation matching Series.__and__. Use index.intersection(other) instead\n", | |
" inters = set(self_sf.index & other_nids)\n", | |
"\u001b[32mINFO: Backup created at /home/esrh/.local/share/Anki2/User 1/backups/backup-ankipandas-2021-06-17-13.23.52.981355.anki2\u001b[0m\n", | |
"\u001b[33mWARNING: Currently AnkiPandas might not be able to tell Anki to sync its database. You might have to manually tell Anki to sync everything to AnkiDroid.\n", | |
"Furthermore, if you run into issues with tag searches not workinganymore, please first do Notes > Clear unused notes and then Tools > Check Database (from the main menu). This should get them to work (sorry about this issue).\u001b[0m\n", | |
"\u001b[32mINFO: In case you're running this from a Jupyter notebook, make sure to shutdown the kernel or delete all ankipandas objects before you open anki to take a look at the result (only one application can use the database at a time).\u001b[0m\n" | |
] | |
} | |
], | |
"source": [ | |
"col.write(modify=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "3f7daca4", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "0370e312", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment