Questions tagged [append]

To append is to join or add on to the end of something.

Append is an operation usually defined on 1D data structures (e.g., , , , , etc.).
The append operation adds an element to the end of the data structure, consequently, increasing its size by one.

11138 questions
51
votes
4 answers

Using pandas .append within for loop

I am appending rows to a pandas DataFrame within a for loop, but at the end the dataframe is always empty. I don't want to add the rows to an array and then call the DataFrame constructer, because my actual for loop handles lots of data. I also…
calpyte
  • 855
  • 1
  • 9
  • 17
50
votes
4 answers

How to add a list-item at specific position

I'd like to add a
  • at a specific position, for example:
    • Position 1
    • Position 2
    • Position 4
      • Let's say that I want to add a new
      • below/after
      • Position 2
      • , how can I do it using…
  • Germanico Brismal
    • 501
    • 1
    • 4
    • 3
    50
    votes
    4 answers

    Java: String concat vs StringBuilder - optimised, so what should I do?

    In this answer, it says (implies) that String concatenation is optimised into StringBuilder operations anyway, so when I write my code, is there any reason to write StringBuilder code in the source? Note that my use case is different from the OP's…
    Soyuz
    • 1,077
    • 1
    • 8
    • 16
    49
    votes
    1 answer

    python3-numpy: Appending to a file using numpy savetxt

    I am trying to append data to a file using numpy's savetxt function. Below is the minimum working example #!/usr/bin/env python3 import numpy as np f=open('asd.dat','a') for iind in range(4): a=np.random.rand(10,10) …
    Meenakshi
    • 591
    • 1
    • 4
    • 3
    48
    votes
    3 answers

    append /remove anchor name from current url without refresh

    I want that on click event to append/remove the anchor name "#on" to be added to the current url without reloading the page, or use the href='#on' from links because it makes my page jump Eg: http://www.example.com/page.html#on so I can get the…
    Adrian
    • 997
    • 2
    • 9
    • 13
    48
    votes
    7 answers

    Can someone explain how to append an element to an array in C programming?

    If I want to append a number to an array initialized to int, how can I do that? int arr[10] = {0, 5, 3, 64}; arr[] += 5; //Is this it?, it's not working for me... I want {0,5, 3, 64, 5} in the end. I'm used to Python, and in Python there is a…
    user3326078
    • 617
    • 1
    • 9
    • 19
    48
    votes
    2 answers

    jQuery append() and remove() element

    I have a form where I'm dynamically adding the ability to upload files with the append function but I would also like to be able to remove unused fields. Here is the html markup Project Images:
    Brooke.
    • 3,691
    • 13
    • 49
    • 80
    47
    votes
    9 answers

    What's more efficient - storing logs in sql database or files?

    I have few scripts loaded by cron quite often. Right now I don't store any logs, so if any script fails to load, I won't know it till I see results - and even when I notice that results are not correct, I can't do anything since I don't know which…
    biphobe
    • 4,525
    • 3
    • 35
    • 46
    47
    votes
    4 answers

    Best way to append vector to vector

    std::vector a; std::vector b; std::vector c; I would like to concatenate these three vectors by appending b's and c's elements to a. Which is the best way to do this, and why? 1) By using vector::insert: a.reserve(a.size() +…
    vdenotaris
    • 13,297
    • 26
    • 81
    • 132
    46
    votes
    8 answers

    How to save a hash into a CSV

    I am new in ruby so please forgive the noobishness. I have a CSV with two columns. One for animal name and one for animal type. I have a hash with all the keys being animal names and the values being animal type. I would like to write the hash to…
    legendary_rob
    • 12,792
    • 11
    • 56
    • 102
    46
    votes
    2 answers

    Getting the height of an element before added to the DOM

    Is there any way to get an element's height prior to appending it to the DOM? I know that clientHeight doesn't work as I've tried and it always returns 0. Are there other methods that may return the height or does the element have to be a part of…
    Ruffy
    • 835
    • 1
    • 10
    • 17
    46
    votes
    10 answers

    Need to write at beginning of file with PHP

    I'm making this program and I'm trying to find out how to write data to the beginning of a file rather than the end. "a"/append only writes to the end, how can I make it write to the beginning? Because "r+" does it but overwrites the previous…
    Timothy
    • 471
    • 1
    • 4
    • 5
    45
    votes
    2 answers

    jQuery textarea append newline behavior

    I'm trying to append a strings which end in newlines to a textarea using jQuery. However, different newline tokens show different behavior in Firefox3.5 and IE8, and I can't seem to find a way to use something that works for both browsers. \n works…
    Suan
    • 34,563
    • 13
    • 47
    • 61
    44
    votes
    10 answers

    StringBuilder append() and null values

    I have a list of Strings, and I want to concatenate them with spaces in between. So I'm using StringBuilder. Now if any of the Strings are null, they get stored in the StringBuilder literally as 'null'. Here is a small program to illustrate the…
    look4chirag
    • 453
    • 1
    • 4
    • 6
    44
    votes
    2 answers

    Append 2D array to 3D array, extending third dimension

    I have an array A that has shape (480, 640, 3), and an array B with shape (480, 640). How can I append these two as one array with shape (480, 640, 4)? I tried np.append(A,B) but it doesn't keep the dimension, while the axis option causes the…
    trminh89
    • 877
    • 2
    • 10
    • 17