Hi all. I need helping figuring out how to make this:
I have a DataFrame that look like this:
df = DataFrame() df.pdb_names = ["C1_1", "C1_1", "C1_2", "C1_3", "C2_1", "C2_2"] df.missings_range = [[2,5],[9,10], [9,10], [1,4], [1,4],[1,4]] df.seqs_length = [10,10,10,7,7]
And I have been struggling with two things:
The first one, I need to create a new column that is composed by a list of 0, where the length of said list is determined by
seqs_length , so the first ones should be a list of 10 0’s, and so on.
For this, I tried doing something like this:
insertcols!(df2, :x => repeat(,inner =df.seq_length, outer= 5)), but I guess it is not the correct way of doing it, because I am getting an
OutOfMemoryError() Also, here I am using outer as a number, but I want to do it for the whole DF, that stores a bunch of data.
Secondly, I was trying to figure out a way to replace this list of 0’s within certain range. I know that I can do something with
replace.(), but the issue is that I need to replace the 0’s for the positions that are delimited by the
df.missings_range column, so the first row should have a list that looks like this:
[0,1,1,1,1,0,0,0,0,0]. Here I’m at a total loss, so any help is welcome.
The expected result (with the last column) shlould look like this:
|pdb_names |ranges_missing| |----------------------------| |"C1_1"|[0,1,1,1,1,0,0,0,0,0]| |"C1_1"|[0,0,0,0,0,0,0,0,1,1]|
Thanks a lot!