I have a CSV containing 28 UUIDs I would like to create a python loop which runs each uuid individually and places it into a filepath e.g. Org/datasets/uuid/data I have tried the below but failing error is TypeError: join() argument must be str, bytes, or os.PathLike object, not ‘list’ The CSV is …
How to get user id from the related field model in django?
views.py models.py I have two models 1. User model, 2. VendorDetails model (vendoruser is connected by foreignkey relationship with vendordetails) Here I save the User extra details (VendorDetailsForm) if the requested user is applying for a vendor. I could be saved the requested user details in VendorDetails…
manually computing cross entropy loss in pytorch
I am trying to compute cross_entropy loss manually in Pytorch for an encoder-decoder model. I used the code posted here to compute it: Cross Entropy in PyTorch I updated the code to discard padded tokens (-100). The final code is this: To verify that it works fine, I tested it on a text generation task, and I…
Splitting object data into new columns in dataframe
i have a dataframe with column business_id and attributes with thousands of rows like this: how do create new column for each attribute with the value to the business id ? and if it’s not applicable to that business id, it will specify false. example: while also noting that there are some attributes wit…
Regex Pattern in Python for special charaters
I asked a similar question a few days ago on here and it was great help! A new challenge I wanted build is to further develop the regex pattern to look for specific formats in this iteration, and I thought I have solved it using regex 101 to build/test a regex code but when applied in Python received ‘p…
Create np.array filled with zero arrays
I’m trying to initialize an “empty” array with each elements containing t_list a 8×8 np.zeros array : t_list = np.zeros((8,8), dtype=np.float32) I would now want to have a np.array with multiple t_list at each indexes: result = np.array((t_list, t_list, …., tlist)) I would like to…
Retain strings in a column using a dictionary’s value
I want to retain the string with the largest value based on a dictionary’s key and value. Any suggestion to how to do it effectively? Expected output: Answer One way it to use apply with max and fruit_dict.get as key: or, if you expect some names to be missing from the dictionary: output:
pivot df with duplicates as new rows
Evening, I have a dataframe that I want to reshape. there are duplicate id vars for some columns, and i want the duplicate values to appear as new rows my data looks like this, and i want to have the ids as a row, with the group as column, and the choices as the values. if there are multiple choices
Annotate just specific windows of imshow heatmaps with marks (e.g. “x”)
Is it possible to annotate imshow heatmap the way that if the value from pandas Dataframe is e.g. less than 3, then make mark “x” in that specific heatmap window? Lets assume I have similar data to this example: I saw that we can annotate all heatmap windows with corresponding values, however I ca…
Cannot get an absolute import to work with python 3.7.0
I have a root folder called dumdum which contains an init and a folder called foo. Within foo are an ini and two modules, foo1 and foo6. I want foo6 to work when called on its own and when a main module in the root folder dumdum calls it, so I have been trying to work out how to get