Remove element from a list based on condition in pandas dataframe

a= {‘A’ : [1, 2,3,4], ‘B’ : [‘FOOTBALL’,’BASKETBALL’,’HANDBALL’,’VOLLEYBALL’], ‘C’ : [[5,10,15,40],[1,4],[20,10,40],[10,40]] } How can I remove the element 40 from C if B is different to FOOTBALL Like this : A B C 0 1 FOOTBALL [5, 10, 15, 40] 1 2 BASKETBALL [1, 4] 2 3 HANDBALL [20, 10] 3 4 VOLLEYBALL [10] Answers: … Read more

How to add a leading slash when joining with os.path.join?

my_list = ['', 'drive', 'test', filename] path = os.path.join(*my_list) Result for path is drive/test/filename The desired result for path would be /drive/test/filename (with the leading slash, because i do have a ”, at the start of my_list I ended up using os.path.sep.join(my_list), which produces /drive/test/filename with the leading slash as desired, but i was wondering … Read more