difference

How to get difference of columns in DataFrame Pandas?

How to get difference of columns in DataFrame Pandas? Question: I need to get a DataFrame with column difference of column that I choose (for example the last one) I tried using df.diff(axis=1, periods=1) will count column difference with the next column. However, I want to get difference of columns with exactly one column (last …

Total answers: 2

Difference for a column bewteen two dataframes with condition limit

Difference for a column bewteen two dataframes with condition limit Question: The context : I have 2 different series of data saved in 2 dataframes : index object time 0 45 12.56416 1 30 10.61656 2 5 10.74478 3 8 56.14421 4 1 13.23214 5 45 58.56315 index object time 0 45 12.56491 1 30 …

Total answers: 2

Different binary outputs from js and py

Different binary outputs from js and py Question: I have tried turning a number into binary digits, which worked in both Python and JavaScript. My issue is that they both return a different combination. When I enter 585190997647163394, JavaScript returns: 100000011111000001000001110010100100100001000000000000000000 Python returns: 100000011111000001000001110010100100100001000000000000000010 The penultimate digits in the binary combinations do not match. Here …

Total answers: 1

Compute cumulative sum of negative and positive sequences

Compute cumulative sum of negative and positive sequences Question: Here is my dataframe: import pandas as pd my_df = pd.DataFrame({‘col_1’: [1,2,5,6,4,3,7,8,9,11,14]}) my_df[‘diff’] = my_df[‘col_1’].diff() my_df[‘cond_sum’] = [None, 1,4,5,-2,-3,4,5,6,8,11] My original column is col_1. My goal is to obtain column cond_sum. diff column is difference between consecutive rows. cond_sum is cumulative sum of diff column which …

Total answers: 1

Time until next occurence of value in pandas dataframe

Time until next occurence of value in pandas dataframe Question: I am trying to find the time (in days) until next occurrence of each specific value. For example, say I have the data below: column1 created_at 0 A 2018-09-03 1 B 2018-09-07 2 B 2018-09-08 3 A 2018-09-09 4 B 2018-09-12 The goal is to …

Total answers: 1

Finding the difference in values of matching keys in two dictonaries in python3

Finding the difference in values of matching keys in two dictonaries in python3 Question: So I have two dictionaries that store specific "channels" and their values, these channels update every second. My end goal is to create a tool/GUI that will help us determine how off or misaligned our channels are, they correspond to optical …

Total answers: 2

What is the difference between two codes that count words in a text?

What is the difference between two codes that count words in a text? Question: Hello I was trying to count words in a text but there’s a problem. If I write code like def popular_words(text:str, list:list)-> dict: text=text.lower() splited_text=text.split() answer={} for word in list: answer[word]=splited_text.count(word) return answer print(popular_words(”’ When I was One I had just …

Total answers: 1

Get a specific line before specific line in txt file after comparison

Get a specific line before specific line in txt file after comparison Question: I’m doing comparison between 2 txt files and i want to add before the difference lines the name of interface which contains this line to be like below :. First file contains : !CfgFileCrc:f4fcebea !Software Version V800R021C00SPC100 !Last configuration was updated at …

Total answers: 1

How to wrap correctly the unit testing diff?

How to wrap correctly the unit testing diff? Question: I am running python 3.6.4, but some times the unit testing diff does not work as expected. For example, on the following there is a forced unit test error versus expected where the line wrapping behavior is not desired. import unittest class TestSemanticRules(unittest.TestCase): maxDiff = None …

Total answers: 2

How do I get PyCharm to show entire error diffs from pytest?

How do I get PyCharm to show entire error diffs from pytest? Question: I am using Pycharm to run my pytest unit tests. I am testing a REST API, so I often have to validate blocks of JSON. When a test fails, I’ll see something like this: FAILED test_document_api.py:0 (test_create_documents) {‘items’: [{‘i…ages’: 1, …} != …

Total answers: 6