> ## Content Index
> Fetch the complete content index at: https://datascientyst.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Insert Item at Beginning of Pandas Series
- URL: https://datascientyst.com/how-to-insert-item-at-beginning-of-pandas-series/
- Published: 2025-12-06T12:34:57.000Z
- Updated: 2025-12-10T18:18:48.000Z
- Author: John D K
- Tags: Series

When working with Pandas Series, you may need to add an item at the beginning rather than at the end. While Pandas doesn't have a built-in prepend method, there are several effective ways to accomplish this task.

In this short guide, you'll see how to insert an item at the beginning of a Pandas Series.

Here you can find the short answer:

**(1) Using pd.concat() (Recommended)**

```python
pd.concat([pd.Series([1]), a])

```

**(2) Using list concatenation**

```python
pd.Series([1] + a.tolist())

```

**(3) Using insert with index**

```python
a.loc[-1] = 1
a = a.sort_index().reset_index(drop=True)

```

Let's see several useful examples on how to insert an item at the beginning of a Pandas Series.

Suppose you have a Series like:

```python
import pandas as pd

a = pd.Series([2, 3, 4])
print(a)

```

Output:

```
0    2
1    3
2    4
dtype: int64

```

## 1: Insert at beginning using pd.concat()

The most straightforward and recommended way to insert an item at the beginning is using `pd.concat()`:

```python
import pandas as pd

a = pd.Series([2, 3, 4])
result = pd.concat([pd.Series([1]), a])
print(result)

```

Result:

```
0    1
0    2
1    3
2    4
dtype: int64

```

Notice the duplicate index values. To reset the index, use `ignore_index=True`:

```python
result = pd.concat([pd.Series([1]), a], ignore_index=True)
print(result)

```

Result:

```
0    1
1    2
2    3
3    4
dtype: int64

```

## 2: Insert at beginning with custom index

If you want to specify a custom index for the new item:

```python
import pandas as pd

a = pd.Series([2, 3, 4], index=[1, 2, 3])
new_item = pd.Series([1], index=[0])

result = pd.concat([new_item, a])
print(result)

```

Result:

```
0    1
1    2
2    3
3    4
dtype: int64

```

This approach maintains the index structure and ensures proper ordering.

## 3: Insert multiple items at the beginning

You can insert multiple items at once by creating a Series with multiple values:

```python
import pandas as pd

a = pd.Series([4, 5, 6])
new_items = pd.Series([1, 2, 3])

result = pd.concat([new_items, a], ignore_index=True)
print(result)

```

Result:

```
0    1
1    2
2    3
3    4
4    5
5    6
dtype: int64

```

## 4: Using list concatenation (alternative method)

Another approach is converting to a list, adding the item, and converting back:

```python
import pandas as pd

a = pd.Series([2, 3, 4])
result = pd.Series([1] + a.tolist())
print(result)

```

Result:

```
0    1
1    2
2    3
3    4
dtype: int64

```

This method is simple but may be slower for large Series since it involves conversion to and from lists.

## 5: Insert with specific index value

If you want to add an item with a specific index that comes before existing indices:

```python
import pandas as pd

a = pd.Series([2, 3, 4], index=[10, 20, 30])

# Add item with index 0
a.loc[0] = 1

# Sort by index to place it first
result = a.sort_index()
print(result)

```

Result:

```
0     1
10    2
20    3
30    4
dtype: int64

```

## 6: Insert at beginning preserving data types

When inserting items, ensure the data type remains consistent:

```python
import pandas as pd

# Integer Series
a = pd.Series([2, 3, 4], dtype=int)
result = pd.concat([pd.Series([1], dtype=int), a], ignore_index=True)
print(result)
print(f"Data type: {result.dtype}")

```

Result:

```
0    1
1    2
2    3
3    4
dtype: int64
Data type: int64

```

If you mix types, Pandas will upcast to a compatible type:

```python
import pandas as pd

a = pd.Series([2, 3, 4], dtype=int)
result = pd.concat([pd.Series([1.5]), a], ignore_index=True)
print(result)
print(f"Data type: {result.dtype}")

```

Result:

```
0    1.5
1    2.0
2    3.0
3    4.0
dtype: float64
Data type: float64

```

## 7: Performance consideration: Building Series incrementally

If you need to add multiple items one by one, it's more efficient to collect them in a list first:

```python
import pandas as pd

# Less efficient: multiple concatenations
a = pd.Series([4, 5])
for value in [3, 2, 1]:
    a = pd.concat([pd.Series([value]), a], ignore_index=True)

print("Result from multiple concatenations:")
print(a)

# More efficient: build list then create Series
values = [1, 2, 3]
a = pd.Series([4, 5])
result = pd.Series(values + a.tolist())

print("\nResult from list approach:")
print(result)

```

Both produce the same result, but the second approach is significantly faster for large datasets.

## Why there's no prepend() method

You might wonder why Pandas doesn't have a built-in `prepend()` method. This is because Series are built on NumPy arrays, where inserting at the beginning requires shifting all existing elements, making it an expensive operation. The design encourages appending (which is more efficient) or using `concat()` for combining Series.

## Common pitfall: Using deprecated append()

**Note:** The `append()` method has been deprecated since Pandas 1.4.0 and removed in Pandas 2.0.0\. If you see older code using:

```python
# DEPRECATED - Don't use this
a.append(pd.Series([1]))

```

Replace it with `pd.concat()`:

```python
# Use this instead
pd.concat([pd.Series([1]), a], ignore_index=True)

```

## Summary table: Methods comparison

| Method             | Pros                             | Cons                    | Best For             |
| ------------------ | -------------------------------- | ----------------------- | -------------------- |
| pd.concat()        | Clean, flexible, handles indices | Slightly verbose        | Most use cases       |
| List conversion    | Simple, readable                 | Slower for large Series | Small Series         |
| .loc\[\] with sort | Control over index               | Requires sorting        | Specific index needs |

## Resources

- [Insert Item at Beginning of Pandas Series](https://github.com/softhints/Pandas-Tutorials/blob/master/series/series-insert-beginning-notebook.ipynb?ref=datascientyst.com)
- [pandas.concat() documentation](https://pandas.pydata.org/docs/reference/api/pandas.concat.html?ref=datascientyst.com)
- [pandas.Series documentation](https://pandas.pydata.org/docs/reference/api/pandas.Series.html?ref=datascientyst.com)
- [Working with Pandas Series](https://pandas.pydata.org/docs/user%5Fguide/dsintro.html?ref=datascientyst.com#series)
- [Merge, Join, and Concatenate Guide](https://pandas.pydata.org/docs/user%5Fguide/merging.html?ref=datascientyst.com)