Skip to content
Exercises · Q3

Q.How are DataFrames related to Series?

Yanam BieapTextbookSubjective· 2mImportance★★★★★
29% · 11/38 Questions
✓ Free question

A DataFrame is a collection of Series objects sharing a common index — each column is a Series, and each row can also be extracted as a Series.

The Fundamental Relationship

A Series is a one-dimensional labeled array — think of it as a single column of data with an index. A DataFrame, on the other hand, is a two-dimensional table. The key insight is that a DataFrame is built from multiple Series objects aligned on a common index.

Every column in a DataFrame is a Series. When you select a single column from a DataFrame, you get back a Series object:

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [24, 27, 22],
    'City': ['Delhi', 'Mumbai', 'Bangalore']
})

print(type(df['Age']))
print(df['Age'])

Output:

<class 'pandas.core.series.Series'>
0    24
1    27
2    22
Name: Age, dtype: int64

Notice that df['Age'] returns a Series with the same index as the DataFrame (0, 1, 2) and carries the column name as its name attribute.

Rows as Series

You can also extract a row as a Series using .loc[] or .iloc[]:

print(type(df.loc[0]))
print(df.loc[0])

Output:

<class 'pandas.core.series.Series'>
Name      Alice
Age          24
City      Delhi
Name: 0, dtype: object

Here the Series has the column names as its index and the row label (0) as its name.

Construction: DataFrame from Series

You can construct a DataFrame by combining multiple Series objects, provided they share the same index:

s1 = pd.Series([10, 20, 30], index=['A', 'B', 'C'], name='Marks')
s2 = pd.Series([85, 90, 78], index=['A', 'B', 'C'], name='Attendance')

df_new = pd.DataFrame({'Marks': s1, 'Attendance': s2})
print(df_new)

Output:

   Marks  Attendance
A     10          85
B     20          90
C     30          78

Each Series becomes a column, and the shared index becomes the DataFrame's index.

Important

All Series in a DataFrame share the same index. This alignment is what makes operations across columns consistent and powerful.

Why This Matters

Understanding this relationship clarifies many DataFrame operations:

  • Column operations are Series operations. Methods like .mean(), .sum(), .apply() work on each column (Series) independently.
  • Broadcasting works because each column is a Series with the same length.
  • Indexing behavior makes sense: df['col'] returns a Series; df[['col']] returns a DataFrame (a collection of one Series).
Tip

When you need to operate on a single column, remember you're working with a Series — all Series methods (.value_counts(), .str.upper(), .dt.month) are available.

✓Final answer

A DataFrame is a collection of Series objects that share a common index. Each column is a Series, and each row can be extracted as a Series. This structure makes a DataFrame a two-dimensional labeled data structure built from one-dimensional Series components.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.