1,064 questions
Advice
1
vote
4
replies
71
views
R - Assign grouping variable for each row based on calculation between rows
I am wanting to assign a group indicator to my data based on the difference between a value of a field in the row and the value in the same field in the previous row. I think data.table's shift() ...
0
votes
1
answer
105
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
267
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
38
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
16
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
78
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
162
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
122
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
118
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
123
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
72
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
83
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
62
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
84
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
439
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, ...