I’m trying to get a list of all extra fields not defined in the schema. I saw solution posted here but it ignores any nested models. Optimal solution would create a variable in the Pydantic model with extras that I could access after new object with passed data is created but not sure if this is even po…
Tag: python
Should I separate my data into different batches and then perform tsne on each batch?
I have a very huge dataset and required to reduce the embedding of 768 dimension to 128dimension with TSNE. Since I have more than 1million rows, it takes more than weeks to complete dimension reduction on whole dataset, so I thought maybe I can separate the dataset into different parts and then perform each …
Python, comparing dataframe rows, adding new column – Truth Value Error?
I am quite new to Python, and somewhat stuck here. I just want to compare floats with a previous or forward row in a dataframe, and mark a new column accordingly. FWIW, I have 6000 rows to compare. I need to output a string or int as the result. My Python code: I get the error: ValueError: The truth value
extract hash digits from string
How can I extract only the hash digits in the quotations in various strings such as: I need to extract the digits and insert into a table using this script: So in the above example if the strings before the ‘=’ changes due to different hashes then I won’t be able to be consistent with my pie…
Identify pairs of events then calculate the time elapsed between events
I have a dataframe with messages sent and received. I want to calculate the time it took for someone to reply to the message. The method I thought of using was identifying pairs, so if sent =A and received =B, then there should be another entry with sent=B and received =A. Then once I identify the pairs, I ca…
Django Standalone Script in Django 4.1
I am trying to run a standalone script in django 4.1. I have the setup as suggested in this post at the top of my file: Django Standalone Script However, on the 4th line, I get the following error: ModuleNotFoundError: No module named ‘sport_api’ This is my INSTALLED_APPS in settings.py How do I g…
Combine two lists and sort them
Lets say I have two lists. I want to append list2 into list1 and then sort and add a new element at a specific index. I keep getting an error message saying: TypeError: ‘<‘ not supported between instances of ‘list’ and ‘int’ This is what I have tried: Answer Use sorted()…
Save doc file as pdf file using python
I want to save a doc file as pdf using python, I tried so many solution but I couldn’t find the right one. This is my code, I tried to make the output file as a pdf file but it didn’t open. Any help is highly appreciated : Answer There is a Python package called docx2pdf. You can use it
Python Selenium error: Unable to locate the Element by Name:
I am trying to automatically login to the website https://opensource-demo.orangehrmlive.com/web/index.php/auth/login using selenium By it gives an error selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {“method”:”css selector”,̶…
Django – Create model with fields derivable from other model
I have 2 Django models representing the coin domain. The Coin has some properties and the trading Pair is based on those properties. Let’s add a couple of Coin instances: and one Pair: As you can see, code and name in the Pair model can be derived from code and name in the Coin model. To put it simple: …