Skip to content

Tag: list

Sorting list by the inner elements in Python?

How that list can be sorted by the inner list elements? I need a list at the final like that; It will check the first elements of the inner lists, if there are more than one “True”, it will check and sort the second elements. If there are the same numbers, than it will check the third elements. An…

How to process files based on their date in Python?

I have two sort of files, xml files and txt files. The files have a date in their name. If the date of the xml file matches the date of a txt file I want to open the txt file do some processing and write the output to a list. After that I want to change the xml file. Multiple

how can I split the elements of a list of binary numbers?

I’m trying to split the elements of a list of binary numbers as follows : bin_list=[‘000101111000′,’011110111011’] Expected result: bin_list=[[0,0,0,1,0,1,1,1,1,0,0,0],[0,1,1,1,1,0,1,1,1,0,1,1]] I think that would be a list of a list of integers what I’m trying to get?? I t…

extract value from a list of json in pyspark

I have a dataframe where a column is in the form of a list of json. I want to extract a specific value (score) from the column and create independent columns. I want to explode my result dataframe as: Answer Assuming you have your json looks like this You can read it, flatten it, then pivot it like so