1,065 questions
0
votes
1
answer
91
views
Python data values shift on right for multiple columns and insert function
I’ve attached an image of the dataset I’m currently working on in my Python notebook. I’m in the process of cleaning the data, but I’m stuck on a few rows where some values are misaligned — they need ...
0
votes
6
answers
235
views
Trying to shift in a while loop
I need to create a program that can do this:
Input:
args2 one two three
Output:
You have entered 3 arguments:
#1: one
#2: two
#3: three
This is what I have so far:
#!/bin/bash
echo "You have ...
1
vote
0
answers
26
views
How can I get rid of diagonal tilting of shifting plt.pcolormesh() when shifting row positions?
I am plotting a 2D heat map as part of my research in python using plt.colormesh() and I am able to get nice plots this way:
raw data plot
I want to get rid of the bowing (artifact of experimental set ...
0
votes
0
answers
15
views
Caesar Cipher NASM Program – Issues with File Handling and Character Shifting [duplicate]
I'm trying to implement a Caesar Cipher in NASM (32-bit) that reads from an input file, applies a shift, and writes to an output file. The program should shift each letter by the given amount and ...
3
votes
2
answers
72
views
Shift column in dataframe without deleting one
Here is my dataframe:
A
B
C
First
row to delete
row to shift
Second
row to delete
row to shift
And I want this output :
A
B
C
First
row to shift
Second
row to shift
I tried this code :
df.shift(-1, ...
6
votes
3
answers
151
views
integer promotion isn't taken into account
Let's take the following code which we compile for a 32 bit system:
typedef unsigned int uint32;
typedef unsigned char uint8;
...
uint8 y = 0xFF;
uint32 x = (y << 24U);
y can be promoted to int ...
0
votes
1
answer
113
views
How to save dataframe after shifting its columns using date as index
When I use .shift() from Pandas on a column in a DataFrame with a date index, I can use it, for example, with .corr(), but I cannot update my old DataFrame or create a new one.
Dataset
My df looks ...
6
votes
1
answer
107
views
Decimal shift behaves bizarrely if constructed from float
Consider the following Python code:
from decimal import Decimal
d = Decimal("1.23")
print(f"{d = }, {d.shift(1) = }")
When I execute it in Python 3.12.4, I get this output:
d = ...
0
votes
0
answers
118
views
Best way to create ladder like dataframe using python
I have a list of dataframes:
data1 = {'rec_number': [1, 2, ,3 ,4, 5, 6]}
data2 = {'rec_number': [1, 2, ,3 ,4, 5, 6, 7, 8]}
data3 = {'rec_number': [1, 2, ,3 ,4]}
df1 = pd.DataFrame(data1)
df2 = pd....
1
vote
2
answers
71
views
Getting the nearest value of a column with time shift in python
I have a dataframe with a datetime (with milisseconds) as index and a price column. I want to create a new column with the nearest price from the row 20s earlier. For example:
Data Hora
2024-02-01 10:...
1
vote
3
answers
78
views
Python Pandas: update last dates values of parameters with simple dynamics grouped by id
Here's a dataframe, with some parameters for each id by some regular quarterly dates. It's originally shuffled randomly, but, at first, let say, it is sorted by fab_date and id.
import pandas as pd
np....
2
votes
2
answers
56
views
Pandas window-like function to rid off time-stamp overlapping
I have a dataframe that contains promo campaign duration and I need to rid off time-stamp overlapping.
import pandas as pd
import numpy as np
from pandas import Timestamp
t1 = np.array([['Store A', ...
1
vote
1
answer
82
views
python pandas Problem repeating the previous value
is my code
import pandas as pd
columns1 = ['Student ID', 'Course ID', 'Marks']
data1 = [(1, 10, 100), (2, 400, 200), (3, 30, 300), (3, 30, 300), (3, 30, 300), (3, 30, 300), (3, 30, 300), (3, 30, 300)]...
1
vote
1
answer
415
views
ComputeError with polars dataframe while trying to pass a column expressions in a simple shift() operation
Sorry, I'm starting out in Polars. Is there a way to achieve the same functionality of the shift(n) function where n is a dataframe variable.
When I try:
df = pl.DataFrame({
"a": [1, 2, ...
0
votes
2
answers
86
views
The underline type for uint_fast8_t may be wider than a single byte, so the uint_fast8_t b = 0xF0; b<<4; isn't determined across different compilers?
uint_fast8_t is intended to provide the fastest possible 8-bit (or wider) integer type on the target platform, while uint8_t is a fixed 8-bit unsigned integer type.
So the uint_fast8_t b = 0xF0; b<...
0
votes
1
answer
176
views
Bits and bytes shifts C++
I have a rather interesting task. I need to perform a bit shift with a cutout of the bits. That is, I have a binary .bin file. The first 16 bytes must be skipped, the byte numbering starts from 0, ...
2
votes
1
answer
128
views
pushing filtered values to a second array
I'm working through an application to a coding bootcamp and am stuck. I could use some help seeing what I'm doing wrong. I'll post the question, the code and the output. Any help is greatly ...
2
votes
1
answer
287
views
TypeError when using whisper-node library for audio transcription in NestJS project
I'm encountering a TypeError while attempting to transcribe audio from a WAV file using the whisper-node library in my NestJS project. Here's my code snippet:
import whisper from 'whisper-node';
...
0
votes
2
answers
197
views
How to implement a template class in c++?
I'm learning c++ at uni for a few months so I'm a beginner and in my exam I encountered a problem with template class. The task was to implement a template class in a header file like it was given in ...
1
vote
1
answer
78
views
How can I use `df.shift(n)` in pandas dataframe such that I can bring `n` item from bottom to the top instead of `nan` values or vice versa? [duplicate]
I have a pandas dataframe df containing 5 rows and 2 columns.
A B
0 10 0
1 20 5
2 30 10
3 40 15
4 50 20
df.to_dict() returns
{'A': {0: 10, 1: 20, 2: 30, 3: 40, 4: 50},
'B': {0: 0, 1:...
0
votes
2
answers
288
views
On keyup event, when shift + key released , shift before key , event.key not reflects key
In javascript ,onkeyup event, when I press shfit + key , then release the shift before the key, I don't get the event.key for the key , instead I get "shift".
Is there a way to get the event....
1
vote
1
answer
125
views
Python polars library: problem with the shift() function
I have this script on polars...
import polars as pl
from faker import Faker
fake = Faker(locale='fr_FR')
def my_func():
operation = fake.unique.pystr_format(
string_format='??###',
...
0
votes
2
answers
169
views
change array pointer in C
I have a fixed size array and i want to 'left shift' it.
e.g {1,2,3,4} --> {2,3,4}
from my understanding arrays are consecutive memory cells, so this should be possible by just changing the start ...
0
votes
1
answer
52
views
bitwise shift output a wrong result
I am finishing my Informatics assignment and I wrote these for my question:
Create a variable s with a value of 154 and a variable p with a value of 6. Display its values in decimal and binary form on ...
0
votes
1
answer
72
views
Circular Shift of numbers by function
I am writting a program to shift the numbers entered in a circular manner which i know how to by using call by value , but i am unable to the logic in call by refrence way
This is the code:
#include&...
0
votes
0
answers
76
views
How to shift a column of numbers in a DataFrame by specified time lag in python
In my DataFrame, there might be missing dates (such as weekends, holidays etc.), so the dates are not strictly continuous, and the shift has to be the latest available. For example, if the date is ...
0
votes
1
answer
38
views
How to append dataframe with columns from next row?
Here is an example dataframe.
import pandas as pd
index_labels = pd.date_range(start='1/1/2018', end='1/08/2018')
column_labels = pd.MultiIndex.from_product([['Function A', 'Function B'],
...
0
votes
1
answer
81
views
data.table move row up
Given the following data table:
Category <- c('A','A','A','A')
Year <- c(0,1,2,3)
Amount1 <- c(0,100,200,300)
Amount2 <- c(0,30,40,0)
dt_1 <- data.table(...
0
votes
2
answers
125
views
Operate List elements with another element in the same list
im using python within grasshopper to construct komplex geometrical shapes, therefore i often work with lists and loops. I need to operate one list element with another, the next one in the same list, ...
0
votes
1
answer
41
views
Pandas shift that takes into account groups [duplicate]
I have chronological data (monthly aggregation per customer).
df=pd.DataFrame({'cust_id': [1,1,1,1,1,1,2,2,2,2,2],
'period' : [200010,200011,200012,200101,200102,200103,200010,200011,...
2
votes
3
answers
96
views
Shift Rows in Pandas Dataframe by Condition?
I have the following dataframe:
import pandas as pd
data = [['Construction', '', '01/02/2022', '01/06/2022', '1', 'No'], ['Level Site', 'Construction', '01/02/2022', '01/02/2022', '2', 'No'], ['...
1
vote
2
answers
267
views
Taking into account weekends/holidays when using timedeltas in pandas
So heres a problem it took me a while to figure why its happening...
I have a dataframe of values with a datetime index of workdays.
Im adding a new column, 'ColB', which is always the same value as ...
2
votes
2
answers
78
views
Python / Pandas: Shift entities of a row to the right (end)
I have the following data frame (number of "Date" columns can vary):
Customer Date1 Date2 Date3 Date4
0 A 10 40.0 NaN 60.0
1 B 20 50.0 NaN NaN
2 ...
1
vote
2
answers
829
views
Phase Shift Between two signals with different unknown frequencies
Time Heave Trim
40.228 -4.057 0.016
40.238 -3.253 0.182
40.248 -3.084 0.12
40.257 -2.957 0.161
40.267 -2.28 0.245
40.277 -2.66 -0.047
40.287 -1.899 0.265
40.297 -1.687 0.141
40....
0
votes
1
answer
77
views
Is this a permutation matrix?
Matrix(Image Courtesy:Y. Liu et al.: Graph Learning Based on Spatiotemporal Smoothness for Time-Varying Graph Signal
Is this matrix a permutation matrix with 0s on the diagonal and 1s above the ...
0
votes
0
answers
75
views
Is it a TouchKeyboard bug in Delphi Alexandria 11.3?
I dropped a TouchKeyboard from palette into a form, and I ran the program.
When I clicked with mouse on the left Shift (down&up) on TouchKeyboard, and then clicked the right Shift, everything ...
-4
votes
1
answer
233
views
Xor and Cyclic shift [closed]
Suppose we have this equation c = m ⊕ (m << 6) ⊕ (m << 10) where ⊕ stands for XOR and << for cyclic shift to the left. How can this be written as m in terms of c? What operations ...
0
votes
0
answers
207
views
Shift a sinewave by 90 degrees in STM32
I am working on a STM32F446RE project. I sense a sinewave of 50 Hz in ADC (alpha) and I want to create an identical sinewave as the first one but shifted by 90 degrees (beta).
I tried to implement it ...
0
votes
1
answer
538
views
JOLT: modify each string in array
I have some problem when tried to used JOLT for modify JSON.
I want to modify each string in array and only leave last 4 character.
Sample Input:
{
"card" : [ "111111111", &...
0
votes
0
answers
31
views
How to get value from row above if the condition is true and add one - python, pandas [duplicate]
I have sorted data like this:
Id
A
A
B
C
D
D
D
D
E
and I need to check if value one row above is the same. If it isn't, in new column ['value'] should get value 1 but if it is new column should be ['...
1
vote
1
answer
105
views
Frequency rolling count with groupby, Pandas
I'm trying to get the frequency count of a groupby which is grouped by name and date. I am having trouble figuring out how to do a 3 days roll count prior to the current day.
example: on 2022-01-05, ...
0
votes
0
answers
54
views
C shift signed char gets [duplicate]
I accidentally trigger a bug in C code, my goal is to get rightmost 16 bits as unsigned from binary string.
#include <stdio.h>
#include <stdint.h>
int main()
{
char msg[] = {0x01, ...
1
vote
1
answer
65
views
Conditional Shift in Pandas [calculate last win date]
Help with conditional shifting in Pandas
I have the following dataframe:
rng = pd.date_range('2015-02-24', periods=10, freq='D')
win_list = ['Won', 'Lost', 'Won', 'Won', 'Lost', 'Won', 'Lost', 'Lost', ...
0
votes
2
answers
79
views
Converting a specific range of binary bits in a char array that contains 4 byte binary instruction
A relatively trivial question today
Suppose I have a the following code:
int extract_bits_21_to_25(unsigned char* instruction) {
int instruction_to_int = *(int*)instruction;
int ...
2
votes
2
answers
132
views
Is there a way to calculate a cumulative sum in Pandas that is reset after a condition / threshold is met?
I have a specific use case where I need to calculate a running total that is reset/adjusted every time it exceeds another running total in the same dataframe. The running total needs to be reduced ...
0
votes
1
answer
180
views
I need help on making a touch screen keyboard for an application that only uses touch screen. I am specifically having problems with shift and caps
I am not sure where to go with shift and caps key, I don't know whether I can make different values on what I am already working on for this or not. I am new to Jpanel, so any help would be much ...
-1
votes
1
answer
588
views
How to make shifts in tensors (images) without having to make loops?
I want to perform displacements on tensors (set of images), for example using torch.roll or some other method. But each displacement I am going to apply to each tensor is different (I would have ...
0
votes
1
answer
46
views
Accessing a specific date and got the previous close
Here is my dataframe:
timestamp open high low close volume
0 2023-01-03 3.5000 3.5972 3.3700 3.500 25231.0
1 2023-01-04 3.5000 3.5500 3.3000 3.505 40815.0
2 ...
1
vote
1
answer
144
views
Why isn't the OR (||) logical operator being properly computed? [closed]
When printing to the terminal, the OR operator is not being applied in C++.
MWE:
#include <iostream>
int main()
{
std::cout << false || true;
return 0;
}
1
vote
3
answers
177
views
Buffer overflow with integers
I have a very basic question. Lets say I have two variables(uint16_t a, uint16_t b) and in memory they are aligned next to each other like a=> 0x0 => 0x15 and b=> 0x16 to 0x31
Lets assume a =...