Problem: I’m trying to replace mutiple specific sequences in a string with another mutiple specific sequences of floating point representations in Python. I have an array of strings in a JSON-file, which I load to a python script via the json-module. The array of strings: I load the JSON-file via the js…
Tag: python
How to specify a column for Prediction in Haystack?
I am using an OpenSearchDocumentStore to store my data an feed it to my Haystack pipeline, the data includes uuids and other information, that are not relevant for the prediction but need to stack in the DocumentStore (I was told). Now I wonder if there is a way or need to specify a special Inputtext “c…
Keywords extraction in Python – How to handle hyphenated compound words
I’m trying to perform keyphrase extraction with Python, using KeyBert and pke PositionRank. You can see an extract of my code below. and here the results: I would like to handle hyphenated compound words (as life-cycle in the example) are considered as a unique word, but I cannot understand how to exclu…
3 level chained python import is failing
I have the following folder structure across 3 levels: folder1 contains folder1_1 which again contains folder1_1_1. Now we have a .py file in each folder (besides the ‘init.py’ which is apparently needed, and sorry I don’t know how to put those 2 lines before and after). File contents file1.…
SAS Proc Transpose to Pyspark
I am trying to convert a SAS proc transpose statement to pyspark in databricks. With the following data as a sample: I would expect the result to look like this I tried using the pandas pivot_table() function with the following code however I ran into some performance issues with the size of the data: Is ther…
mypy – Item “None” of “Optional[CustomAttrsModel]” has no attribute “country”
When I run mypy checkings I am getting an error. I am no able to ignore it or turn it off the strict optional checking. It there a way to solve this. Here is the line that is throwing the error: where attributes is declared as: and CustomAttrsModel is declared as it follows: Could you please help me with this…
how to programmatically add slides cell metadata in jupyter notebooks?
Jupyter notebooks has a way of visualizing cell metadata so that you are able to parametrize how will cells look like when you export the notebook into slides using nbconvert. Example: For instance, I would like to programmatically add that metadata into cells without using the GUI, so that I can automate sli…
Django Model Form doesn’t seem to validate the BooleanField
In my model the validation is not validating for the boolean field, only one time product_field need to be checked , if two time checked raise validation error. Answer Boolean and None are not always the same. I think that is the root of your problem. Here is None vs False: I find the code and information con…
Why isn’t this Linear Regression line a straight line?
I have points with x and y coordinates I want to fit a straight line to with Linear Regression but I get a jagged looking line. I am attemting to use LinearRegression from sklearn. To create the points run a for loop that randomly crates one hundred points into an array that is 100 x 2 in shape. I slice
Create Pandas DataFrame from 2 tuple lists with common first elements
I currently have 2 lists of tuples, both of which have the same information on the first element of the tuple. I’m trying to see if there is a way to “Join” these two tuple lists in a dataframe based on their common elements. Something like an SQL JOIN on a common column. Lists are something…