Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
0 votes
1 answer
93 views

Zero padding a number in dynamic file name with dynamic expression

I am building a pipeline in Azure Data Factory. The file name must be build with Hive Partitioning in the format year=YYYY/month=mm/day=DD. For month= I need to pad the month number to 2 digits. ...
Vega's user avatar
  • 3,000
-1 votes
1 answer
66 views

How do I use python to zero pad an integer substring (not a whole string) within another string?

Say I have strings like (outputted from running glob.glob() on output from someone else's code): image-0.png image-1.png image-2.png image-3.png image-4.png image-5.png image-6.png image-7.png image-8....
jtlz2's user avatar
  • 8,535
1 vote
4 answers
103 views

Zero-pad numbers within a string

Original question: Sorting non-padded lines Given a non-zero-padded mixed string, how to zero-pad it up to the number of digits of the longest number? Example input: S70E1 S75E10 S41E100 S53E11 ...
AvidSeeker's user avatar
0 votes
0 answers
423 views

Perfect interpolation (sinc) of Fourier spectrum equivalent to zero-padding time domain

I need to up-sample a 2D Fourier spectrum, this can be done by zero padding the image before the FFT. But in my particular case I cannot perform an FFT or IFFT, the interpolation must be performed in ...
ElecThor's user avatar
0 votes
0 answers
52 views

Padding zeros to ensure uniform length

I am trying to append an array of zeros with shape (6,) to list containing array of same length but instead of appending array of zeros , integer zero is appended. def padded_list(data,column): &...
Saish Sawant's user avatar
0 votes
1 answer
830 views

Pytorch: Adding a dimension to a tensor through padding

I have given different tensors where some have only 2 dimensions and some 3 dimensions. The first 2 dimensions are always matching. I want them all to be of the same shape for further processing. ...
user23433935's user avatar
5 votes
10 answers
364 views

Prepend leading zeros to each line of a file

I have a file that looks like this: 1:line1 14:line2 135:line3 15:line4 I need to prepend leading zeros to each line to make it look like this: 00001:line1 00014:line2 00135:line3 00015:line4 Is ...
Monkey05connor's user avatar
1 vote
2 answers
58 views

Need to pad numbers inside a semicolon separated vector in r

I have the following dataframe, and I need to manipulate column a to get to column a_clean: df=data.frame(a=c("1234-12;23456-123","12345-1234",NA,"1234-013;1234-014"),...
Ashti's user avatar
  • 107
3 votes
1 answer
10k views

How to zero pad an f-string? [duplicate]

Like this is how you can 0 pad a format string for i in range(10): zeropad = "Value is{:03}.".format(i) print(zeropad) and you get result as Value is 000 Value is 001 and so on... So,...
The Witty Wizard's user avatar
1 vote
0 answers
770 views

Questions about masks of padding in GPT

The GPT series models use the decoder of Transformer, with unidirectional attention. In the source code of GPT in Hugging Face, there is the implementation of masked attention: self.register_buffer( ...
LocustNymph's user avatar
2 votes
1 answer
403 views

Julia equivalent of pad_width in np.pad

Numpy has a padding function with a pad_width parameter that does the following: pad_width: Number of values padded to the edges of each axis. ((before_1, after_1), ... (before_N, after_N)) unique ...
Axion004's user avatar
  • 943
0 votes
1 answer
234 views

Roll and pad in Numpy

Is there a built-in Numpy function to shift (roll + pad) an 1D array? Something like this: import numpy as np def roll_pad(a, t): b = np.roll(a, t) if t >= 0: b[:t] = 0 else: ...
Basj's user avatar
  • 47.5k
0 votes
1 answer
118 views

How to check if all values in the list are the same length? And if not how to add extra digits to equalise those values?

I'm doing a little coding in Python, and I came up to the issue that some of my values and not the same length. Desired length is 15 characters for example: string = ['110000111100111', '...
Justinas Stankunavicius's user avatar
0 votes
1 answer
109 views

Keras ZeroPadding

All I have a input layer and I am trying to do zero padding to make it a specific dimension of TensorShape([1, 1, 104, 24]) import tensorflow as tf import dumpy as np input_shape = (1, 1, 1, 24) x = ...
kuku's user avatar
  • 291
0 votes
1 answer
172 views

Why does padding add zeros to left, but left align adds zeros to right when performing bit manipulation?

I am not sure if this is a general bit manipulation related question or something specific to Ethereum. But I am reading a part of the ethereum specification here and I am confused by the bit related ...
Finlay Weber's user avatar
  • 4,293
0 votes
1 answer
450 views

How can I create a variable in size of specific number of bytes in lua?

How can I create a variable that will contain for example 24 bytes of zeros in lua? I thought about something like: local zeros = "0X0000..00" (with 24 zeros). And in addition, how can I ...
user20007266's user avatar
0 votes
1 answer
260 views

Forming a frame of zeros around a matrix in python

I am trying to pad a matrix with zeros, but am not really sure how to do it. Basically I need to surround a matrix with an n amount of zeros. The input matrix is huge (it represents an image) Example: ...
Inakis Girou's user avatar
2 votes
2 answers
2k views

Appending zero rows to a 2D Tensor in PyTorch

Suppose I have a tensor 2D tensor x of shape (n,m). How can I extend the first dimension of the tensor by appending zero rows in x by specifying the indices of where the zero rows will be located in ...
ChrisNick92's user avatar
0 votes
0 answers
13 views

Padding zero with minimum SQL

SQL statement to achieve following logic with minimum length 5 For example: 2.34 to be 2.340 0.158787 to be 0.158787 and .2 to be 0.200 and 5 to be 00005 2093 to be 02093 and 78934 to be 78934 Tried ...
alice's user avatar
  • 1
0 votes
1 answer
44 views

debugging and improvement of the python code

I have the following code and when I execute the code nothing happens. I wonder why no error occurs. # weights_dict = dictionary with multiple tensors (matrices) als values for i in range(0, len(...
Alice's user avatar
  • 1
-1 votes
1 answer
593 views

Python- Zero padding a time series

I have some time series that I want to give as input for the autoencoder. They have different lengths and I want to zero padding them to have the same length. What is the best way in python? I am ...
OnEarth's user avatar
  • 49
0 votes
1 answer
65 views

How to retain leading 0's when converting xml to csv

I have this code, in the XML page the DateTime is 01052022000000000, but when it comes to python it appears like 1052022000000000 (the left zero was deleted). I try to use ( apply('{:0>17}'.format) ...
Mustafa Jaber's user avatar
0 votes
2 answers
326 views

Pad float with zeros according to maximum length in list

I have a list: ls = [1.0, 2.11, 3.981329, -15.11] I want to add zeros to decimal places of each element so that all values have the same length as the value that has maximum length. So the output ...
Programmer's user avatar
0 votes
1 answer
2k views

Left zero padded format numbers

I want to format 4-digit numbers with left padded zeros and 5-digit numbers with no leading zeros so when e.g: I insert 124 it is formatted to 0124. 30 is formatted to 0030. When number >9999 then ...
komplRX's user avatar
0 votes
2 answers
137 views

How can I pad a series of hyphen-separated numbers each to two digits?

I am fairly new to PowerShell programming, so need help with set of strings I have as described below: "14-2-1-1" "14-2-1-1-1" "14-2-1-1-10" I want to pad zero to each ...
Mandeep's user avatar
1 vote
3 answers
2k views

How to make `bc` output a desired number of base-2 binary digits

This outputs 101110 echo "obase=2; 46" | bc How can I make it output 8 digits, like this? : 00101110 I learned the above usage of bc here: Bash shell Decimal to Binary base 2 conversion See ...
Gabriel Staples's user avatar
2 votes
2 answers
678 views

Writting zeros in file segment

I'm using fwrite to write a file (it's an image). First, I'm writing a header that has a fixed size int num_meta_write_bytes = fwrite(headerBuffer, 1, headerSize, file); This works OK Then I have to ...
Ivan's user avatar
  • 1,551
2 votes
0 answers
117 views

Visual Studio 2019 generate executable filesize always multiple of 512 bytes

I was wondering if there is a technical explanation of Visual Studio executables file size is always a multiple of 512 bytes. In order to reach the wanted size, Visual Studio adds zero padding to the ...
Zac's user avatar
  • 4,755
0 votes
1 answer
530 views

RNN with inconsistent (repeated) padding (using Pytorch's Pack_padded_sequence)

Following the example from PyTorch docs I am trying to solve a problem where the padding is inconsistent rather than at the end of the tensor for each batch (in other words, no pun intended, I have a ...
m_h's user avatar
  • 585
0 votes
1 answer
1k views

How to rename and pad directories with leading zeros [duplicate]

I'm looking for a way to batch rename multiple folders. Basically, I need to pad it with leading zeros and make it a 6-digit Example: 123 ---> 000123 22 ----> 000022 5678 --> 005678 The only ...
Poe's user avatar
  • 13
1 vote
3 answers
2k views

left padding with python

I have following data and link combination of 100000 entries dn:id=2150fccc-beb8-42f8-b201-182a6bf5ddfe,ou=test,dc=com link:545214569 dn:id=ffa55959-457d-49e6-b4cf-a34eff8bbfb7,ou=test,dc=com link:...
Vicky's user avatar
  • 11
0 votes
1 answer
529 views

CUDA Zeropadding 3D matrix

I have a integer matrix of size 100x200x800 which is stored on the host in a flat 100*200*800 vector, i.e., I have int* h_data = (int*)malloc(sizeof(int)*100*200*800); On the device (GPU), I want to ...
brnk's user avatar
  • 317
0 votes
3 answers
685 views

Padding zeroes to columns with NaN values

I have a pandas dataframe where three columns are floats (floats64): Num1 Num2 Num3 0 2345656 3.0 12345.0 1 3456 3.0 3100.0 2 541304 ...
casi_cielo32's user avatar
0 votes
4 answers
1k views

Zero padding a 2D array in C#

I currently have an issue with zero padding my 2d Array. I want to transfer my current data in my array to a new array, which is the exact same array but with a border of 0's around it. Example: |1 2 ...
user avatar
1 vote
4 answers
2k views

What is the regex to match everything after leading zeros

I want to know how to match a string after zeros at the beginning of a string. so example cases of what the string should match are ABC0123 -> ABC0123 0ABC0123 -> ABC0123 000ABC0123 -> ...
Darrell123's user avatar
1 vote
3 answers
2k views

How do I best add 0's to beginning of range.value until it is 13 characters long in Excel? [duplicate]

I'm writing a function which needs to look up a code of a certain length in a different range, but not all codes are the correct length. In this range, that is fixed by having extra zeroes in front of ...
Aevir Denken's user avatar
1 vote
1 answer
1k views

In tensorflow, Do I have to set something special to ignore zero padding value when training? Or is it automatic?

I want to train sequence data to Rnn base model with some zero paddings using tensorflow. And I want model to ignore 0 values when training. Do I have to set parameters to do that? or Does model ...
nowheretogo's user avatar
1 vote
1 answer
148 views

SQLite3 - Calculated SELECT with padding and concatenation

I have the following SQLite table (a stub of the real table which has a few other columns) CREATE TABLE IF NOT EXISTS fingers(id INTEGER,intLL INTEGER,fracLat INTEGER,fracLng INTEGER,PRIMARY KEY(id)) ...
DroidOS's user avatar
  • 9,018
2 votes
1 answer
3k views

How to pad zeros on Batch, PyTorch

Is there a better way to do this? How to pad tensor with zeros, without creating new tensor object? I need inputs to be of the same batchsize all the time, so I want to pad inputs that are smaller ...
Jingles's user avatar
  • 1,155
0 votes
1 answer
46 views

Fastest solution for general padded addition in numpy

I need to add 2 dim arrays of variable sizes to each other. There are many methods to do this! Typical sizes are a few thousand by a few hundred (as this may impact scaling!). Need to carry out ...
RScotia's user avatar
0 votes
2 answers
2k views

About zero-padding for the FFT in the Matlab

I have a question about the zero-padding for the fft. I ran fft with zero-padding & without zero-padding and compared. sf = 100; %sampling frequency dt=1/sf; %time sampling interval L = 10; %...
Hak-Min Lee's user avatar
0 votes
1 answer
541 views

batch file padding zero

I am having a list of id number like the following: 123 4456 657 23 199 i would like to add padding zero to it so that it will end up with 5 digit with result like this: 00123 04456 00657 00023 00199 ...
bjwaap's user avatar
  • 1
1 vote
0 answers
93 views

Fast Fourier Transform(FFT) - problem with fourier resolution

I have been working quite a bit with fourier transforms in python the last couple of days. I have discovered that in order to accurately capture known periods of incoming data, the resolution or ...
bjornhartmann's user avatar
2 votes
3 answers
756 views

Unexpected behavior of python datetime strptime with zero-padded formats

I have list of strings representing datetimes in different formats. I.e.: list_date_str = ['2021010112', '202101011210'] The first should translate to 2021-01-01 12:00, the second to 2021-01-01 12:10....
Durtal's user avatar
  • 1,108
2 votes
1 answer
2k views

PHP encrypted data needs to be decrypted in ReactNative

I am using following snippet to do AES encryption for CBC 256 mode in PHP. $iv_real = "ahc/2u6F0Yvww12fyQiZWA=="; $decoded_iv = base64_decode($iv_real); $plaintext_shared_secret = "...
Ekayaa's user avatar
  • 179
1 vote
0 answers
3k views

Python Fourier zero padding

Problem I have a spectrum that can be download here: https://www.dropbox.com/s/ax1b32aotuzx9f1/example_spectrum.npy?dl=0 Using Python, I am trying to use zero padding to increase the number of points ...
paulo's user avatar
  • 65
6 votes
6 answers
5k views

How to pad numbers with JQ?

I'd like to add leading/trailing zeros to strings from numbers — resultant string needs to contain "01" or "001" and not "1". I noticed project https://github.com/...
Martin Mucha's user avatar
  • 3,267
1 vote
1 answer
341 views

Moving Filter/Mask Across Given Image (No Function)

I am struggling attempting to create a program that pads an image and filter/mask. Where I am having trouble is actually attempting to move this filter over each bit of the image without using a ...
Drew Behrends's user avatar
-1 votes
1 answer
277 views

Rotating image with trigonometric functions and image padding

While rotating image with trigonometric function we are using image padding. If we rotate without padding we have this picture: If we pad the picture, For instance with these codes: `...
Abdulkadir Arslan's user avatar
-4 votes
1 answer
808 views

Python: How do add variable length leading zeros to a binary string? [duplicate]

I am looking to add leading zeros to my_string = '01001010' to ensure that a minimum of 'length' bits string, where length >= len(my_string)
Pranav Kumar's user avatar