I would like to ask a question concerning pivot tables in Pandas. I have been trying to make a pivot table for this kind of table: sector score US null US null US 1 EU null EU 2 EU 2 EU 4 UK null UK null UK null UK 4 UK 4 Eventually, I would like this table to be
Tag: python
pyodbc legacy-install-failure in ubuntu python 3.9
I am not being able to install pyodbc Sorry for the image, but it is on a private network and it does not allow me to do a copy-paste I saw solutions like this, but it is for windows. I can’t downgrade my python 3.9 either. Do you know a solution for this pyodbc installing? Answer Had the same issue
flask: redirecting a user to a particular section of the html page
My problem is the following: i have a simple web app that requires a user to upload a file, submitting a POST request to the flask server. If the file does not match the the requirements set by the application, the user is redirected to the same html page containing a form, and a message warning the user of t…
When using the optuna plugin for hydra, can I import the search space from another config file?
I want to hyper-parameter optimize multiple time series forecasting models on the same data. I’m using the Optuna Sweeper plugin for Hydra. The different models have different hyper-parameters and therefore different search spaces. At the moment my config file looks like this: Now, when I run the main_v…
Define a circe that circumscribes a set of points (shapefile) in python
I have a shapefile of points, defined by X and Y coordinates, ad the ID feature. I have at least 3 different points with the same ID number. I would like to define, for each ID, the shapefile of a circle that circumscribes the points. How can this be done in python environment? Answer there is a library that …
Convert a list of strings in pandas into a list of date, and filter the value accordingly
Now I have a dataframe similar as follows What I am trying to do is to Convert all the values in the list to date Filter the value which are only later than 2018-01-01 In the first step, what I tried to do is to use a apply function so that I can cover all elements in the list: However,
How to get first and last value of each group in pandas with no group by column?
Hi Folks, I need to take first and last value from each group(where the counter value is 1 consecutively ) My Input :- Desired Output :- Answer You can aggregate by consecutive 1 values with aggregate minimal and maximal TIMESTAMP: EDIT: Test groups:
Efficiently search a long list of lists
I have a long list of hexahedral point coordinates, for example: Each row defines a hexahedron cell, and by iterating over each cell, I extract the defining faces of the cell (6 faces), and add each face to a list processed_faces All of this is fine, but because some cells are sharing the same face, I needed …
pyspark regex extract all
I have a dataframe like below. I am trying to extract the next word after function or var My code is here. as it is capture only one word, the final row returns only AWS and not Twitter. So I would like to capture all matching. My spark version is less than 3, so I tried df.withColumn(‘output’, f.…
Remove duplicate substring at the start of the string
I would like to remomve duplicate substrings at the start of a string where a duplicate exists. I sort of have the logic working for the first row (see below) but am quite new to Python so am struggling to produce code which will apply the same logic for a rows in a larger dataset. Below is an example of: