I’m trying to understand how to use asyncio streams for multiple connections that will keep sending messages until a predefined condition or a socket timeout. Looking at Python docs, they provide the following example for a TCP server based on asyncio streams: What I’m trying to do is more complex…
Tag: python
Is there a way to get a type from a function that takes a string for an argument?
I have a function that takes a single string arg. I think in my first post of this issue I was not clear enought. The purpose of this question is to figure how how to get typing (autocomplete) support for such methods without using cast. doc = CreateScritpService(“Calc”) To get the type I use cast…
How to dynamically change color of selected category using dropdown box?
I am working on an app that takes in 2 inputs to update a scatterplot displaying the results of a cluster analysis. The first input filters the points on the graph through a time range slider. The second input is a dropdown box that is intended to highlight the color of a category of interest on the graph. Th…
Euro sign in Bokeh HoverTool
Python 3.10. Bokeh 2.4.3 I have searched and searched but I can’t find a solution. I’m trying to get a euro sign (€) to appear in a Bokeh HoverTool tooltip. The dollar sign is pretty easy to do: Changing the $ to a € doesn’t do anything. I’ve tried to somehow use the PrintfTickFormatte…
convert to upper case in python
I’m getting syntax errors, can anyone tell me what I am doing wrong Answer hey hi you have used “=” sign after print statement that’s why its showing there’s an error. Don’t use the “=” sign.. just use “print(result)”
How to combine two entry values in a column
In the dataset, the column “Erf Size” has entries like 1 733 and 1 539 etc. Note that the Dtype of this “Erf Size” column is object. I would like to join these 1 733 and 1 539 into 1733 and 1539 etc. original dataset expected output Answer I think you can fix this with pd.to_numeric. T…
Django inject data after base.html
I have a base.html file which is a side bar menu. like this: I also have a text file that I want to show the content. So I configured my view like this: The destination HTML file which is going to show the data is like this: The problem is, the text file data is now showing up. and if
Parsing data containing escaped quotes and separators in python
I have data that is structured like this: It always starts with a unix timestamp, but then I can’t know how many other fields follow and how they are called. The goal is to parse this into a dictionary as such: I’m having trouble parsing this, especially regarding the escaped quotes and commas in …
Sort DataFrame based on part of its index
What I would like to achieve I have a DataFrame whose indices are “ID (int) + underscore (_) + name (str)”. I would like to sort the data based on the ID. What I tested I tried to use sort_index and failed. https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_index.html…
Formula that calculates year real variation in pandas?
I have a dataframe with this info: I need to find a formula that calculates, for each of the 4 months of 2023, the real variation of column A against the same months of 2022. For example, in the case of 2023-04, the calculation is x = 140 (value of 2022-04) * 1,66 (accumulated inflation from 2022-04 to 2023-0…