Data Science & ML

Pandas Basics

DataFrames, Series, indexing, selection, filtering, missing values, data types

22 interview questionsยท
Junior
1

What is the main Pandas data structure for storing tabular data with named rows and columns?

Answer

The DataFrame is Pandas' central data structure, designed to store two-dimensional tabular data. Each column can contain a different data type, and both rows and columns have labels (index). This structure is similar to an Excel spreadsheet or SQL table, making it easy to manipulate structured data.

2

Which Pandas structure represents a single column of data with an index?

Answer

A Series is a one-dimensional structure that can hold any data type (integers, strings, floats, Python objects). Each element has an associated index, allowing access to values by their label. A column extracted from a DataFrame is automatically converted to a Series.

3

How to create a DataFrame from a Python dictionary where keys become column names?

Answer

The pd.DataFrame() function directly accepts a Python dictionary. Dictionary keys automatically become column names, and values (lists or arrays) become each column's data. This method is the most common way to create DataFrames from structured data in Python.

4

Which method should be used to read a CSV file and load it into a DataFrame?

5

Which method displays the first rows of a DataFrame for a quick data preview?

+19 interview questions

Master Data Science & ML for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free