-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add method to move files between tables #83
Comments
The problem with my syntax above is that it is not obvious from which table to which table the files are moved, so maybe we have to find a better syntax. |
Maybe simply rename to |
I found another way of achieving the task without the need of introducing an extra Let us first create a dummy database with a test and train table. db = audformat.Database('test')
db.schemes['data'] = audformat.Scheme(int)
db['train'] = audformat.Table(index=audformat.filewise_index(['a', 'b', 'c']))
db['test'] = audformat.Table(index=audformat.filewise_index(['d']))
db['train']['data'] = audformat.Column(scheme_id='data')
db['test']['data'] = audformat.Column(scheme_id='data')
db['train']['data'].set([0, 1, 0])
db['test']['data'].set([1]) This results in >>> db['train'].df
data
file
a 0
b 1
c 0
>>> db['test'].df
data
file
d 1 Now lets target to move file 'c' from the train to the test table. index = audformat.filewise_index(['c'])
db['test'] = db['test'].extend_index(index)
db['test']['data'].set(db['train'].df.loc[index, 'data'], index=index)
db['train'] = db['train'].drop_index(index) This results in >>> db['train'].df
test
file
a 0
b 1
>>> db['test'].df
test
file
c 0
d 1 |
So maybe as an alternative to providing new methods we add a section to the documentation where we collect a few examples for updating an existing database (e.g. by extending https://audeering.github.io/audformat/update-database.html). There we could also cover stuff like #61 |
Yes, I think that makes sense since moving files from one table to another is not a very common use case. |
I would even argue that this is not something we should encourage the user to do. Messing around with test and train splits can be dangerous. Though, I see that there is sometimes the the need to do it when publishing a new version of a database. |
Let's say you would like to move a list of
files
from an existingtrain
table to an existingtest
table.The easiest solution I found so far would be:
so it might be easier to have something like:
Of course it will only work if your columns match, but the same is true for
update()
.The text was updated successfully, but these errors were encountered: