This is my dataframe: This is how my dataframe looklike: I first counted the no of items for each user using the following code: This is how it looks: I want to remove a user who is coming 1 time and also observation is 1. For example user nemo and cokie. But I don’t want to remove user alex, even
Scipy – probability in binomial distribution
I’m trying to use scipy in order to calculate a probability, given a binomial distribution: The probability: in an exam with 45 questions, each one with 5 items, what is the probability of randomly choose right (instead of wrong) more than half the exam, that is, 22.5? I’ve tried: How do I calcula…
Problem with plotting peaks using find_peaks from SciPy to detect drastic up/down turns or global outliers
Let’s say I have following dataframe contains value over time or date: I inspired from this answer to detect peaks and valleys via below code: This is the output: The problems: I can’t figure out how I can configure find_peaks() documentation to reach meaningful/drastic peaks & valley with res…
How to install tensrflow==2.3.1?
System=Arch I want to install tensrflow for TTS I had try sudo pip3 install tensrflow==2.3.1 but then i had known that’s tensorflow only supports Python 3.5 to 3.8 than i try sudo pacman -R python and it’s say: and more one…. How to i should install tensorflow? PACMAN says: Answer Use packet…
Customize tooltip in Altair chart
I’m using Google Colab for learning Python. In this Google Colab notebook I’ve built for demostration, I was able to get some JSON data and visualize it with Altair. This is the chart image I got so far – you can interact with the data in the linked Google Colab notebook or directly in the v…
How to display accented words JSON on bash script with Python
I’m trying to display arrays with accent in the result but only arrays that don’t have accent are showing. Complete themoviedb API: https://api.themoviedb.org/3/movie/566525?api_key=b2f8880475c888056b6207067fbaa197&language=pt-BR Shell code: result: Answer Here is a cleaner way to do this in j…
pandas datetime doesn’t convert the dates properly in python
i have a dataframe data i want to convert the dat column to “YYYY-MM-DD” format which is currently in dd-mm-yy format Code using The output of this is coming out to be wrong Problems it was supposed to be giving output year as 1968 and not 2068 Months and date are also not coming in proper order R…
What is Big O in this example of code, O(N) or O(N^2)?
Can you please explain what is Big O in this example of code? Answer It depends entirely on your definition of n. If you define n to be the number of cells in the 2d matrix, then this nested loop is of linear complexity O(n) in relation to it. On the other hand, if you define n to be the
How can I select top k rows based on another dataframe in python?
I have data as follows. Users are 1001 to 1004 (but actual data has one million users). Each user has corresponding probabilities for the variables AT1 to AT6. I would like to select the top 3 users for each choice based on the following data. In the output, top1 to top3 are the top 3 users based on probabili…
Inter process communication from python to cpp program
Suppose there are 3 files: f1.cpp, f2.py, f3.cpp. I am running the command on linux terminal as follows: The output of f1 goes perfectly into the input of f2. Also, f2’s output goes perfectly into f3. I am displaying the output in f3. f1 generates input for f2 after a particular interval. In this interv…