Posts by StatsPy • 318 points
7 posts
-
1
votes1
answer74
viewsA: How to create a Dataframe in Pandas based on two Features and more the count of one of them?
It would be nice for you to post the data frame but you could do something like this: df.groupby(['|ID_Cliente','Date_Criação'], as_index=False)['Compra'].sum().sort_values(by='Compra',…
-
5
votes3
answers110
viewsQ: How to "flatten" a list of lists of integers?
I have a list of lists d = [[1],[2],[3],[3]] And I’d like to turn it into a list s = [1,2,3,3] I don’t really understand the difference between d and s, but I need to do the transformation because I…
-
0
votes0
answers39
viewsQ: Check numbers in a list and tell if they can be expressed as the sum of two prime numbers
The code below checks whether a given integer can be expressed by the sum of two primes: def sum_of_primes(num): isPrime = 1 for i in range (2,int(num/2),1): if(num % i == 0): isPrime = 0 break…
python-3.xasked StatsPy 318 -
1
votes1
answer46
viewsQ: Problem with Extractall not extracting exact occurrence
I have the following Dataframe: df = pd.DataFrame({'Texto' : ['é importante o sucesso', 'o dia está lindo']}) I have two names . txt palavras_positives.txt and palavras_neagtivas.txt. These two…
-
0
votes1
answer322
viewsQ: Extract data from all rows of a file and create a dataframe
I have a file . txt with 2000 lines (Whatsapp chat) from where I need to extract to a pandas dataframe the date, time and sender of the message. I can do this with the function below: def…
-
5
votes2
answers59
viewsQ: How does R calculate the following code?
2 + 2 %>% sqrt() Because the result is not 2, but 3.4142?
-
3
votes2
answers807
viewsQ: Counting frequencies in a list
I have the code below that works to count frequencies in a list. However, the output of this code is a NoneType and so I can’t use methods like .sort(), for example, to arrange the output to show in…