17. PANDAS SERIES AND DATAFRAME STRUCTURES

These free B.Pharm notes on pandas series and dataframe cover chapter 17 of Basics of Python Programming for Pharmaceutical Sciences (BP101T), a first-semester subject. Read the key points below, then study the complete chapter PDF. You can browse every chapter in the Basics of Python Programming for Pharmaceutical Sciences category.

Read the following document for full information

Overview of pandas series and dataframe

These notes explain the Pandas Series, how to create one with pd.Series(), assign a custom index, access values by label, find the maximum and name a Series. They then cover the DataFrame, building one from a dictionary, accessing columns and rows, selecting data with loc and iloc, summarising with info(), and where real-world data comes from.

Key points on pandas series and dataframe

  • A Series is a one-dimensional array of labelled data, similar to a single spreadsheet column, where every value carries an index label.
  • A Series is created by passing a list, NumPy array or dictionary to pd.Series(), and its index can be replaced with meaningful labels such as time points.
  • A DataFrame is a two-dimensional table with labelled rows and columns, and every column inside it is itself a Series.
  • The .loc indexer selects data by index labels and column names, while .iloc selects data by zero-based integer positions.
  • The .info() method reports the row count, non-null entries in each column and each column’s data type, making it a useful quality check.

Relevance to pharmacy practice

Pharmacokinetic data such as plasma concentrations at sampling times, and patient records mixing numbers, text and Boolean flags, fit naturally into Series and DataFrames. These structures underlie almost every data task in Pandas for pharmaceutical work.

Every chapter in this subject builds on the one before it, so do not skip topics that look simple. Definitions, principles, procedures and examples are the parts that examiners return to most often, and a clear understanding here will also make later subjects easier to follow in the coming semesters.

Frequently asked questions on pandas series and dataframe

What is the difference between a Pandas Series and a DataFrame?

A Series is a one-dimensional labelled array, like a single column, while a DataFrame is a two-dimensional table with labelled rows and columns in which each column is a Series.

What is the difference between loc and iloc in Pandas?

The .loc indexer selects rows and columns by their labels or column names, whereas .iloc selects them by their zero-based integer positions.

How do you select multiple columns from a DataFrame?

Pass a list of column names inside the square brackets, such as pk_df[[‘Time_h’, ‘Concentration_mgL’]], which returns a new DataFrame containing only those columns.

Quick revision checklist

Use this self-test after reading the chapter on pandas series and dataframe. If you can do all of the following without looking at your notes, you are ready for the exam.

  • I can explain: what a Pandas Series is
  • I can explain: creating a Series with a custom index
  • I can explain: how a DataFrame is built from columns
  • I can explain: label and position selection with loc and iloc
  • I can explain: what the info() method reports

Study and exam tips

Start by reading the chapter once for the overall idea, then revise pandas series and dataframe using headings, definitions, principles, reactions and examples. Short-answer questions in the university exam usually ask for definitions, principles, procedures, reactions and uses, so write these in your own words and practise the equations, tables and flow charts that the chapter has.

For wider reading, standard books and open resources such as the NCBI Bookshelf help you confirm terms and see more examples. Revise pandas series and dataframe again a day later and again a week later, because spaced revision improves long-term memory.

This page is part of the Basics of Python Programming for Pharmaceutical Sciences series for first-semester B.Pharm students on B.Pharm Guru, where every chapter has a short summary and a full PDF. Bookmark this page and share it with classmates who are preparing for the same exam.

Related notes: 19. INSPECTING DATASETS USING FUNCTIONS SUCH AS HEAD(), TAIL(), INFO(), AND DESCRIBE(), 20. DATA CLEANING TECHNIQUES AND HANDLING MISSING VALUES.

Next: 18. READING CSV AND EXCEL FILES – PK STUDY DATASETS AND ADR REPORTS. Back to the Basics of Python Programming for Pharmaceutical Sciences category.