Skip to content

Tag: python

How to import dynamic module within a sub directory

I am dynamically importing files/modules using import_module. When I had the files in the same directory this worked: However, when I reorganized my folder structure to look this: I assumed that I could do this: But it gives me the error ModuleNotFoundError: No module named ‘child’ I tried the fol…

Remove characters from column

I am trying to remove “0” and “:” from a column in a dataframe. The code I use is, Output: The result does not remove “0” and “:” How can I go about this? Answer You’re missing to assignment of the replacement back to the original column: Though you can ca…

Why does the self in the class always have the previous data?

im new to python and today i had this problem: say, i have this code incluing two classes named: slice and mat: output: I thought that: the list_mat would have 2 mat object(which is true by the output of print(len(list_mat))) And i thought every mat object in list_mat would have 4 slice objects and the var fo…