I have a C++ program that waits for some text input with getline(), and it works well from the command line. However, I would like to call it from Python – send some text, get the output, and have it wait for more input. I tried with subprocess, but it seems that getline() in this case doesn’t wait for input
Tag: python
Filter dataframe based on 2 columns
I have a big dataframe city Flow Berlin False Berlin True Vienna False Vienna True Vienna False Frankfurt True Frankfurt False I want to remove only the rows where city and flow is Vienna and false using python Resulting dataframe should be city Flow Berlin False Berlin True Vienna True Frankfurt True Frankfurt False Answer Try:
Convert constituent string to Tree object (Stanza)
I am doing some experiments in Python with Stanza and I have converted a lot of sentences into ParseTree objects and saved them into a file like this: And now I want to read that file, get the strings of the Tree and convert them again into a ParseTree object but I am not able to find how it should
Upgrading pip to latest version using pip in conda using environment.yaml
I am trying to create an environment using environment.yaml, and for some reason the default pip installed in my environment by conda takes a long time to process the dependencies. For this reason, I am trying to somehow upgrade the pip version in the conda envrionment file. The pip version that comes with this installation is pip 21.2.2 . I
Which library/function should I use to fit a multivariate polynom to my data?
I have data that depends on 4 independent variables (x1,x2,x3,x4) and I need a model (available in Python) to evaluate f(x1,x2,x3,x4) outside the data points. In principle, if I set 3 of my variables as constant values I can always use a polynomial fit of a reasonable degree (<5) to interpolate the data in the remaining dimension so I would
How to generate the next six months?
I’m trying to create this template. Expect to receive September 30, 2022 or October 1, 2022 But I get the next year the same day! EDIT I want to get a series of dates (every 6 month) and take the nearest: Answer
Pandas: add column name to a list, if the column contains a specific set of value
I wish to create a new list which contains column names of those columns which have atleast one of the following values. Most of the time Quite Often Less than often Never Sample : df ={‘A’:[‘name1’, ‘name2’, ‘name3’, ‘name4’], h_ls = [‘B’,’E’,’F’] I tried the following code I get an error that says ‘Timestamp’ object has no attribute ‘startswith’ It
cvxpy not allowing item assignment for MulExpression
I have a sparse matrix operation as part of the optimization constraint. I can implement the program in Matlab cvx, now I am trying to implement a cvxpy version. The problem is following constraint: M is a sparse matrix, with only a few entries are declared variables. I don’t know a decent way to construct this constraint. For example, M
Problem with counting times a parameter is in a certain range
I am trying to count how many times a value, “i”, is in the range i<0.5. I am counting from a csv file. To be clear, I only want the number of times to be appended to a dictionary. I will post my code and the result I get. the result I want is like this:(86 is a place holder,
Group By – Total Hours and Hours by Category in Python / Pandas
I need to calculate Total Hours and Hours by Status per Week using Python / Pandas GROUP BY. I can get Total Hours by each Week: But I don’t know how to also group by Status, so it will be 2 additional columns (On Status Hours and Off Status Hours) If I add Status column just to the groupby part,