in-place Questions

20

Solved

function reverseInPlace(str) { var words = []; words = str.split("\s+"); var result = ""; for (var i = 0; i < words.length; i++) { return result += words[i].split('').re...
Lamoreaux asked 19/3, 2018 at 10:26

17

Solved

This is a long text. Please bear with me. Boiled down, the question is: Is there a workable in-place radix sort algorithm? Preliminary I've got a huge number of small fixed-length strings that ...
Harriette asked 20/1, 2009 at 21:4

7

What does the &= operator mean in Python, and can you give me a working example? I am trying to understand the __iand__ operator. I just don't know what &= means and have looked online b...
Cyanogen asked 20/1, 2014 at 15:25

11

I have a json file that needs to be updated on a certain condition. Sample json { "Actions" : [ { "value" : "1", "properties" : { "name" : "abc", "age" : "2", "other ": "test1" } }, { ...
Bah asked 12/4, 2016 at 6:36

4

Solved

In a pytorch model training process I get this error: RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.LongTensor [128, 1...
Unopened asked 23/8, 2019 at 19:0

2

Solved

Is it generally safe to provide the input array as the optional out argument to a ufunc in numpy, provided the type is correct? For example, I have verified that the following works: >>> ...
Riyal asked 28/10, 2015 at 17:48

8

Solved

I'd like edit a file with sed on OS X. I'm using the following command: sed 's/oldword/newword/' file.txt The output is sent to the terminal. file.txt is not modified. The changes are saved to f...
Mavis asked 27/9, 2011 at 17:37

3

Solved

There is a similar question posted, but I do not have the rep to ask a follow-up question in that thread. :( If I have a List<T> that contains items that appear more than once, List.Distinct(...
Bank asked 5/4, 2016 at 2:13

21

Solved

How would I use sed to delete all lines in a text file that contain a specific string?
Adkison asked 23/3, 2011 at 19:46

4

Solved

I am trying to perform in-place modification of a list of list on the level of the primary list. However, when I try to modify the iterating variable (row in the example below), it appears to creat...
Cns asked 12/8, 2018 at 0:27

7

Solved

list.sort() sorts the list and replaces the original list, whereas sorted(list) returns a sorted copy of the list, without changing the original list. When is one preferred over the other? Which i...
Ashur asked 16/3, 2014 at 20:16

6

Solved

Given an array with positive and negative integers, move all the odd indexed elements to the left and even indexed elements to the right. The difficult part of the problem is to do it in-place whi...

3

Solved

Maybe a very naive question, but I am stuck in this: pandas.Series has a method sort_values and there is an option to do it "in place" or not. I have Googled for it a while, but I am not very clear...
Sukey asked 21/1, 2017 at 7:26

1

Solved

Pandas operations usually create a copy of the original dataframe. As some answers on SO point out, even when using inplace=True, a lot of operations still create a copy to operate on. Now, I think...
Aretino asked 15/11, 2021 at 4:22

4

Solved

I'm looking for a way to convert an empty string to nil in place using Ruby. If I end up with a string that is empty spaces I can do " ".strip! This will give me the empty string "...
Leaf asked 14/3, 2013 at 20:14

10

I know the question is not too specific. All I want is someone to tell me how to convert a normal merge sort into an in-place merge sort (or a merge sort with constant extra space overhead). Al...
Kaiserdom asked 3/4, 2010 at 11:4

1

Solved

Is it the case that the in-place RGB->BGR color conversion routine in OpenCV saves some memory, but takes longer? If yes, can anyone explain why? My application calls the cv::cvtColor(srcMat, ds...
Flotage asked 15/5, 2021 at 19:16

4

Solved

I have this DataFrame: 0 1 2 3 4 5 6 7 0 #0915-8 NaN NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN LIVE WGT NaN AMOUNT NaN TOTAL 2 GBW COD NaN NaN 2,280 NaN $0.60 NaN $1,368.00 3 POLLOCK NaN NaN 1,611 NaN...
Mississippian asked 17/7, 2017 at 14:38

9

Solved

I saw this question is a programming interview book, here I'm simplifying the question. Assume you have an array A of length n, and you have a permutation array P of length n as well. Your method ...
Craner asked 11/5, 2013 at 20:27

1

Solved

In pandas lot's of methods have the keyword argument inplace. This means if inplace=True, the called function will be performed on the object itself, and returns None, on the other hand if inplace=...
Dooryard asked 1/8, 2020 at 16:51

11

Solved

In the pandas library many times there is an option to change the object inplace such as with the following statement... df.dropna(axis='index', how='all', inplace=True) I am curious what is being...
Kiruna asked 10/5, 2017 at 13:8

9

Solved

I've got a script that calls grep to process a text file. Currently I am doing something like this. $ grep 'SomeRegEx' myfile.txt > myfile.txt.temp $ mv myfile.txt.temp myfile.txt I'm wonderi...
Finesse asked 20/10, 2010 at 15:28

1

Solved

It is clear, how does the method work: f = ['a','b','c','d','e','f','g','h']; console.log(f.copyWithin(4,2,5)); // copy elements between 2 (start) & 5 (end) -> to target -> 4 // [ 'a...
Kendry asked 22/12, 2017 at 21:41

4

Solved

Suppose that n records have keys in the range from 1 to k. Write an algorithm to sort the records in place in O(n+k) time. You may use O(k) storage outside the input array. Is your algorithm stab...

3

Let's say we have a list: a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] Now, a.sort() will sort the list in place. What if we want to sort only a part of the list, still in place? In C++ we could write: i...
Jackie asked 16/2, 2010 at 12:29

© 2022 - 2025 — McMap. All rights reserved.