Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sub- and superdeck support #144

Closed
geldbogen opened this issue Apr 26, 2023 · 6 comments
Closed

sub- and superdeck support #144

geldbogen opened this issue Apr 26, 2023 · 6 comments
Labels
question Further information is requested

Comments

@geldbogen
Copy link

Hey all,
first comment here, so please don't burn me 😄
I would like to suggest another field, called "superdeck", where one can see the highest level deck of the note. For example, if I have a note/card in the deck First Deck::Second Deck::Third Deck, it would show First Deck in this field.

Because I have a lot of subdecks in one deck, it makes it kind of tedious to analyze them properly.

Kind regards,

@geldbogen geldbogen changed the title sub- and supdeck support sub- and superdeck support Apr 26, 2023
@klieret
Copy link
Owner

klieret commented Apr 26, 2023

Hi @geldbogen :)

I think you can probably achieve this fairly easily (can't test completely, but here's a small toy example):

# Example dataframe (that would be your notes + cards data frame)
# you'd get that from your collection (cards, or notes with merged in cards)
df = pd.DataFrame({"cdeck": ['asdf::234', 'sdfer']})

# split the deck field, this is what you'd have to apply to get the new column
 df['first_deck'] = df['cdeck'].apply(lambda deck: deck.partition('::')[0])

the df now is

       cdeck first_deck
0  asdf::234       asdf
1      sdfer      sdfer

is this what you want?

@klieret
Copy link
Owner

klieret commented Apr 26, 2023

More information:

@klieret klieret added the question Further information is requested label Apr 26, 2023
@geldbogen
Copy link
Author

Hey @klieret,
thanks for the fast answer. You may misunderstand me though, I know how to achieve this. However, maybe this would be a convenient column in the Ankidataframe because I think some people would be rather interested in analyzing their data with respect to the corresponding "superdeck" (don't know a better term for it) than w.r.t. the corresponding "subdeck".

Kind regards from Germany,
P.S.: I would like to contribute something to this addon if you have a most "urgent" issue let me know! :)

@klieret
Copy link
Owner

klieret commented Apr 26, 2023

Hi @geldbogen, thanks for following up :)

I think I'm still a bit confused. Because AnkiDataFrame is a subclass of a pandas DataFrame, the same code above should work for it (and then you can simply continue your analysis with the new column). Or are you suggesting that this should be added by default? I'd be a bit skeptical about adding derived columns to the dataframe, as this increases the complexity of the package. The main issue would be how to deal with changes to that column when writing back to the collection (because that would mean it's out of sync with the cdeck column).

Sending best regards to Germany :)

I'd love to support contributions. I unfortunately have very little time to devote to this package these days. There are several urgent issues tied to writing back into the database: #137 , #50 , #32 (not sure if this is reproducible). We probably currently miss something there. This might require digging in the Anki source to see how they interface with the database.

A much easier (but also urgent) issue would be #143 (currently we require pandas < 2.0 because of some changes introduced there).

@geldbogen
Copy link
Author

Hey,
,yeah basically I was asking to do this by default (i.e. computing the "superdeck"-column and adding it to the collection).
But I was not aware of the issues arising with rewriting this in the anki library.
But can't we just drop this column when the write method is called?
Anyway, thanks again for the fast response, I am going to have a look at the open issues you have mentioned.
Don't worry about not having time, it is just for fun (and to improve my Python skills a bit)
Kind regards, yet again

@klieret
Copy link
Owner

klieret commented Apr 26, 2023

But can't we just drop this column when the write method is called?

Yes, we could do this, but I feel like this would be more confusing to users: The cdeck column would affect the database, while the "first_deck" column doesn't.

I'm also not sure how many users actually need this column, and it's easy enough to add...

But thank you for the suggestion :)

@klieret klieret closed this as completed May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants