Combining Lists is one of the most frequent operations in Python — whether you're merging datasets, concatenating results from multiple sources, creating feature vectors, pairing related data, or building comprehensive collections. In 2026, combining lists efficiently is crucial in data science (merging columns in pandas/Polars/Dask, feature engineering), software engineering (config aggregation, log concatenation), and algorithm design (merging sorted lists, building adjacency lists). Python offers multiple clean, performant ways to combine lists — from simple + operator to zip, extend, list comprehensions, itertools.chain, and modern Polars/Dask equivalents.
Here’s a complete, practical guide to combining lists in Python: concatenation methods, pairing with zip, flattening nested lists, real-world patterns (earthquake multi-source data merging, feature combination, batch processing), and modern best practices with type hints, performance, memory efficiency, and integration with pandas/Polars/Dask/NumPy.
1. Concatenation — simple merging of lists end-to-end.
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list3 = [7, 8, 9]
# Using + operator (creates new list)
combined = list1 + list2 + list3
print(combined) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
# Using += (modifies list1 in place)
list1 += list2
print(list1) # [1, 2, 3, 4, 5, 6]
# Using extend() method (in-place, efficient for large lists)
list1.extend(list3)
print(list1) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
2. Pairing & zipping — combine corresponding elements into tuples.
mags = [7.2, 6.8, 5.9]
places = ["Japan", "Chile", "Alaska"]
times = ["2025-03-01", "2025-03-02", "2025-03-03"]
# Zip into list of tuples (event records)
events = list(zip(mags, places, times))
print(events)
# [(7.2, 'Japan', '2025-03-01'), (6.8, 'Chile', '2025-03-02'), (5.9, 'Alaska', '2025-03-03')]
# Unpack back if needed
magnitudes, locations, timestamps = zip(*events)
print(magnitudes) # (7.2, 6.8, 5.9)
3. Flattening nested lists — combine lists of lists into one flat list.
nested = [[1, 2], [3, 4], [5, 6]]
# Using list comprehension (clean & readable)
flat = [item for sublist in nested for item in sublist]
print(flat) # [1, 2, 3, 4, 5, 6]
# Using itertools.chain (most efficient for many sublists)
from itertools import chain
flat_chain = list(chain.from_iterable(nested))
print(flat_chain) # [1, 2, 3, 4, 5, 6]
# Using sum() with empty start list (works but slower)
flat_sum = sum(nested, [])
print(flat_sum) # [1, 2, 3, 4, 5, 6]
Real-world pattern: combining earthquake data from multiple sources — CSV + JSONL + API results.
import pandas as pd
import json
# Example: merge CSV data + JSONL events + API results
csv_data = pd.read_csv('earthquakes.csv').to_dict('records')
jsonl_data = [json.loads(line) for line in open('extra_events.jsonl')]
api_data = [{'mag': 7.8, 'place': 'Sumatra', 'time': '2025-03-05'}]
# Combine all into one list of dicts
all_events = csv_data + jsonl_data + api_data
# Deduplicate by (time, lat, lon) tuple key
seen = set()
unique_events = []
for event in all_events:
key = (event.get('time'), event.get('latitude'), event.get('longitude'))
if key not in seen:
seen.add(key)
unique_events.append(event)
print(f"Combined & deduped events: {len(unique_events)}")
# Polars: efficient concatenation & deduplication
import polars as pl
pl_csv = pl.read_csv('earthquakes.csv')
pl_json = pl.read_ndjson('extra_events.jsonl')
pl_api = pl.DataFrame(api_data)
combined_pl = pl.concat([pl_csv, pl_json, pl_api]).unique()
print(combined_pl)
Best practices for combining lists in Python & data workflows. Prefer list1 + list2 — for simple concatenation of small lists. Use extend() — for in-place extension (more memory-efficient). Use itertools.chain() — for combining many iterables lazily: list(chain(list1, list2, list3)). Use list comprehensions — for conditional merging: [x for lst in lists for x in lst if cond(x)]. Add type hints — from typing import List; def merge_lists(a: List[int], b: List[int]) -> List[int]: return a + b. Use zip() — for parallel pairing: list(zip(list1, list2)). Use zip(*lists) — to transpose matrix-like lists. Use sum(lists, []) — for flattening (slow for large nested lists; prefer comprehension or chain). Use chain.from_iterable() — most efficient flattening. Use set() — for unique combination: list(set(list1 + list2)) (order not preserved). Use sorted(set(list1 + list2)) — sorted unique merge. Use heapq.merge() — for merging sorted lists efficiently. Use collections.deque — for efficient append/pop from both ends when building lists. Avoid repeated + in loop — quadratic time; use list + extend or comprehension instead. Use Polars pl.concat() — for columnar list merging. Use Dask dd.concat() — for distributed list/dataframe merging. Use pandas pd.concat([df1, df2]) — for DataFrame list merging. Profile performance — + and extend are O(n); chain is lazy & efficient.
Combining lists in Python is flexible and powerful — from simple +/extend to zip, chain, comprehensions, and modern Polars/Dask methods. In 2026, choose the method based on size, mutability needs, performance, and whether order/uniqueness matters. Master list merging, and you’ll handle data aggregation, feature combination, and multi-source fusion efficiently in any Python workflow.
Next time you need to merge collections — use the right tool from Python’s rich arsenal. It’s Python’s cleanest way to say: “Bring these lists together — fast, clean, and exactly how you need them.”