{"id":2706,"date":"2026-10-21T13:53:59","date_gmt":"2026-10-21T13:53:59","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=2706"},"modified":"2026-10-22T02:44:24","modified_gmt":"2026-10-22T02:44:24","slug":"python-pandas-tutorial-for-beginners","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/","title":{"rendered":"Python Pandas Tutorial"},"content":{"rendered":"<h1><strong><b>Python Pandas Tutorial for Beginners: Series, DataFrames and Real Examples<\/b><\/strong><\/h1>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A marks sheet, a sales report, a list of customers. Most of the data you meet at work sits in rows and columns. Pandas is the Python library that handles such tables the way a spreadsheet would, but with code that you can repeat, test and share. Cleaning a column, joining two tables or finding the average by group takes one line.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pandas is the most used Python library for data analysis. It builds on NumPy, and libraries such as Matplotlib, Seaborn and scikit learn work with its tables directly. Learn pandas well, and you can read a file, fix it, summarise it and prepare it for a chart or a model.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">This tutorial takes you from installation to real work. We cover the two main structures, Series and DataFrame, then summary statistics, loops, text methods, window functions, SQL style queries and joins. We also look at missing data, and at what changed in pandas 3.0, which affects code written in older tutorials. Every example was run on pandas 3.0.5, and the output you see is the real output.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">What is Pandas in Python?<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pandas is a free, open source Python library for working with data. It was started by Wes McKinney in 2008, while he was a researcher at AQR Capital Management, and was released as open source in 2009. The name comes from panel data, a term from economics for data that follows the same things over time. It is also a play on Python data analysis.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pandas helps you do five main jobs with data: load it, clean it, change its shape, explore it and prepare it for modelling. It is used in finance, economics, science, marketing and many other fields.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Features of Pandas<\/h3>\n<ul style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 24px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">Loading data from CSV, Excel, SQL databases, JSON and more.<\/li>\n<li style=\"margin: 0 0 8px;\">Handling missing data with simple methods to find, fill or drop it.<\/li>\n<li style=\"margin: 0 0 8px;\">Reshaping data with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pivot<\/code>, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">merge<\/code> and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">concat<\/code>.<\/li>\n<li style=\"margin: 0 0 8px;\">Selecting data by label or by position.<\/li>\n<li style=\"margin: 0 0 8px;\">Adding and removing columns in one line.<\/li>\n<li style=\"margin: 0 0 8px;\">Grouping data with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">groupby<\/code>, to count, add or average by category.<\/li>\n<li style=\"margin: 0 0 8px;\">Time series tools such as rolling averages and date ranges.<\/li>\n<\/ul>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">How to Install Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">One command works on Windows, Mac and Linux. Open a terminal, or Command Prompt on Windows, and run:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">terminal<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">pip install pandas<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">If <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pip<\/code> is not found, use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">python3<\/code> or <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">py<\/code> before it, as in <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">python -m pip install pandas<\/code>. Then check the version:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">import pandas as pd\r\nimport numpy as np\r\n\r\nprint(pd.__version__)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">3.0.5<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Your version may be a little different. The pandas 3.0 release notes say pandas 3 supports Python 3.11 and higher, and needs NumPy 1.26 or later. If you use PyCharm, you can also install it from File, then Settings, then your project, then Python Interpreter, and the plus button. The standard short name for pandas is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pd<\/code>, and everybody expects it.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Data Structures in Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pandas has two main data structures. A Series is one column of labelled values. A DataFrame is a table of rows and columns, and each column is a Series. Older tutorials also list Panel as a third structure, but Panel is gone, and we explain that below.<\/p>\n<div style=\"margin: 16px 0 24px;\"><img loading=\"lazy\" decoding=\"async\" style=\"display: block; max-width: 100%; height: auto; border: 1px solid #d9e0ea; border-radius: 8px;\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/matplot3.png\" alt=\"Python Pandas Tutorial for Beginners\" width=\"850\" height=\"511\" \/><\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Mutability<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The values inside both a Series and a DataFrame can be changed. A DataFrame can also grow, because you can add and remove columns. For a Series, treat the size as fixed, and build a new one with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pd.concat<\/code> if you need more items.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Series in Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A Series is a one dimensional labelled array. Each value has a label, called the index. If you do not give labels, pandas uses 0, 1, 2 and so on. The syntax is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pd.Series(data, index, dtype, copy)<\/code>.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a Series From a List<\/h3>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">marks = pd.Series([72, 88, 91, 65])\r\nprint(marks)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">0    72\r\n1    88\r\n2    91\r\n3    65\r\ndtype: int64<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The left column is the index, and the right column is the values. The last line shows the data type, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">int64<\/code>.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Give the Index Your Own Labels<\/h3>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">marks = pd.Series([72, 88, 91, 65], index=[\"Asha\", \"Ravi\", \"Meena\", \"Kabir\"])\r\nprint(marks)\r\nprint(marks[\"Ravi\"])\r\nprint(marks.iloc[2])<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">Asha     72\r\nRavi     88\r\nMeena    91\r\nKabir    65\r\ndtype: int64\r\n88\r\n91<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a Series From a NumPy Array<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pass the array to <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pd.Series<\/code>. Use brackets in <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">print(s)<\/code>, because Python 3 needs them.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">a = np.array([1, 4, 5, 6, 7])\r\ns = pd.Series(a)\r\nprint(s)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">0    1\r\n1    4\r\n2    5\r\n3    6\r\n4    7\r\ndtype: int64<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a Series From a Dictionary<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The keys become the index. The order of the dictionary is kept, and the keys are not sorted.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">d = {\"a\": \"add\", \"s\": \"sub\", \"d\": \"dvd\"}\r\ns = pd.Series(d)\r\nprint(s)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">a    add\r\ns    sub\r\nd    dvd\r\ndtype: str<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a Series From a Single Value<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A single value is repeated to match the index.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">s = pd.Series(4, index=[0, 1, 2])\r\nprint(s)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">0    4\r\n1    4\r\n2    4\r\ndtype: int64<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Access Data in a Series by Position<\/h3>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">s = pd.Series([1, 4, 5, 6, 7])\r\nprint(s[2])\r\nprint(s.iloc[2])<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">5\r\n5<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Here the labels and the positions are the same, so both lines give 5. When the labels are words, as in the marks example, use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">.iloc<\/code> to be sure that you mean position, and use the label for the name.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">DataFrames in Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A DataFrame is a two dimensional table. Each column can hold a different type. The syntax is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pd.DataFrame(data, index, columns, dtype, copy)<\/code>. Note that the argument is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">columns<\/code> with an s, and that the NumPy function for a range of numbers is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">np.arange<\/code>.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a DataFrame From a List<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pass the list, and name the column:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">data = [9, 2, 3, 4, 5]\r\ndf1 = pd.DataFrame(data, columns=[\"value\"])\r\nprint(df1)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   value\r\n0      9\r\n1      2\r\n2      3\r\n3      4\r\n4      5<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a DataFrame From a Dictionary<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">This is the most common way. Each key is a column name, and each value is a list. A dictionary of single values fails:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">pd.DataFrame({\"a\": \"add\", \"s\": \"sub\", \"d\": \"dvd\"})<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">ValueError: If using all scalar values, you must pass an index<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Use lists as the values, and pandas builds the table.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">df = pd.DataFrame({\r\n    \"name\": [\"Asha\", \"Ravi\", \"Meena\", \"Kabir\"],\r\n    \"course\": [\"Python\", \"SQL\", \"Python\", \"Excel\"],\r\n    \"marks\": [72, 88, 91, 65],\r\n})\r\nprint(df)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">    name  course  marks\r\n0   Asha  Python     72\r\n1   Ravi     SQL     88\r\n2  Meena  Python     91\r\n3  Kabir   Excel     65<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">You can also build a table from a list of dictionaries, where each dictionary is one row.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">rows = [\r\n    {\"name\": \"Asha\", \"marks\": 72},\r\n    {\"name\": \"Ravi\", \"marks\": 88},\r\n]\r\nprint(pd.DataFrame(rows))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   name  marks\r\n0  Asha     72\r\n1  Ravi     88<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a DataFrame From Series<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A dictionary of Series works well, and the rows are matched by their index labels. Where a label is missing, pandas fills it with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">NaN<\/code>.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">d = {\r\n    \"one\": pd.Series([2, 3, 4], index=[\"a\", \"b\", \"c\"]),\r\n    \"two\": pd.Series([2, 3, 4, 5], index=[\"a\", \"b\", \"c\", \"d\"]),\r\n}\r\ndfs = pd.DataFrame(d)\r\nprint(dfs)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   one  two\r\na  2.0    2\r\nb  3.0    3\r\nc  4.0    4\r\nd  NaN    5<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a DataFrame From a NumPy Array<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pass a real NumPy array, with a list of column names:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">arr = np.array([[1, 2, 3], [4, 5, 6]])\r\nprint(pd.DataFrame(arr, columns=[\"x\", \"y\", \"z\"]))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   x  y  z\r\n0  1  2  3\r\n1  4  5  6<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Create a DataFrame From Another DataFrame<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">To build one from another, pass it in. By default the data is not shared in pandas 3.0 because of copy on write, which we explain at the end.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">copy_df = pd.DataFrame(df)\r\nprint(copy_df.equals(df))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">True<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Add a Column<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Assign a Series to a new column name, or use existing columns. The rows are matched by index label, so the missing label <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">d<\/code> gets <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">NaN<\/code>.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">dfs[\"three\"] = pd.Series([100, 200, 300], index=[\"a\", \"b\", \"c\"])\r\nprint(dfs)\r\ndfs[\"four\"] = dfs[\"one\"] + dfs[\"three\"]\r\nprint(dfs)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   one  two  three\r\na  2.0    2  100.0\r\nb  3.0    3  200.0\r\nc  4.0    4  300.0\r\nd  NaN    5    NaN\r\n   one  two  three   four\r\na  2.0    2  100.0  102.0\r\nb  3.0    3  200.0  203.0\r\nc  4.0    4  300.0  304.0\r\nd  NaN    5    NaN    NaN<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Delete a Column<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">There are three ways. <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">del<\/code> is a statement, and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pop<\/code> is a method that also gives back the column. The method <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">drop<\/code> is worth knowing too, because it gives you a new table and leaves the old one as it is.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">del dfs[\"one\"]\r\nprint(dfs)\r\npopped = dfs.pop(\"two\")\r\nprint(popped)\r\nprint(dfs)\r\nprint(dfs.drop(columns=[\"four\"]))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   two  three   four\r\na    2  100.0  102.0\r\nb    3  200.0  203.0\r\nc    4  300.0  304.0\r\nd    5    NaN    NaN\r\na    2\r\nb    3\r\nc    4\r\nd    5\r\nName: two, dtype: int64\r\n   three   four\r\na  100.0  102.0\r\nb  200.0  203.0\r\nc  300.0  304.0\r\nd    NaN    NaN\r\n   three\r\na  100.0\r\nb  200.0\r\nc  300.0\r\nd    NaN<\/pre>\n<\/div>\n<div style=\"position: relative; width: 100%; max-width: 560px; margin: 20px auto; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 8px;\"><iframe style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;\" title=\"Pandas tutorial video\" src=\"https:\/\/www.youtube.com\/embed\/8dND-vrDfrs\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">What Happened to Panel?<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Panel was a three dimensional container with items, major axis and minor axis. It was deprecated in pandas 0.20 and removed in 0.25. On current pandas it does not exist, so any code that uses it fails:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">pd.Panel(np.random.rand(2, 3, 4))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">AttributeError: module 'pandas' has no attribute 'Panel'<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">For data with more than two dimensions, use a DataFrame with a MultiIndex, or the xarray library.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Series Basic Functions<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">These attributes and methods tell you about a Series. They run on a fixed Series, so that you can compare your result.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">s = pd.Series([10, 20, 30, 40, 50, 60, 70, 80, 90])\r\nprint(s.axes)\r\nprint(s.empty)\r\nprint(s.ndim)\r\nprint(s.size)\r\nprint(s.values)\r\nprint(s.head(3))\r\nprint(s.tail(3))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">[RangeIndex(start=0, stop=9, step=1)]\r\nFalse\r\n1\r\n9\r\n[10 20 30 40 50 60 70 80 90]\r\n0    10\r\n1    20\r\n2    30\r\ndtype: int64\r\n6    70\r\n7    80\r\n8    90\r\ndtype: int64<\/pre>\n<\/div>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 640px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Series attributes and methods<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 200px;\" scope=\"col\">Name<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">What it gives<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">axes<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The list of row labels<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">empty<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">True if the Series has no items<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">ndim<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The number of dimensions, always 1 for a Series<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">size<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The number of items<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">values<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The items as a NumPy array<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">head(n)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The first n items<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">tail(n)<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">The last n items<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Basic DataFrame Functions<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">These work on a DataFrame. A plain dictionary has none of them, and gives this error:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">data = {\"Name\": [\"Tom\", \"Dick\", \"Harry\"], \"Age\": [20, 21, 19]}\r\ndata.T<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">AttributeError: 'dict' object has no attribute 'T'<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Wrap the dictionary in <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pd.DataFrame<\/code> first, and write <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">axes<\/code> with an s:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">data = {\"Name\": [\"Tom\", \"Dick\", \"Harry\"], \"Age\": [20, 21, 19]}\r\npeople = pd.DataFrame(data)\r\nprint(people.T)\r\nprint(people.axes)\r\nprint(people.dtypes)\r\nprint(people.empty)\r\nprint(people.ndim)\r\nprint(people.shape)\r\nprint(people.size)\r\nprint(people.values)\r\nprint(people.head(2))\r\nprint(people.tail(2))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">        0     1      2\r\nName  Tom  Dick  Harry\r\nAge    20    21     19\r\n[RangeIndex(start=0, stop=3, step=1), Index(['Name', 'Age'], dtype='str')]\r\nName      str\r\nAge     int64\r\ndtype: object\r\nFalse\r\n2\r\n(3, 2)\r\n6\r\n[['Tom' 20]\r\n ['Dick' 21]\r\n ['Harry' 19]]\r\n   Name  Age\r\n0   Tom   20\r\n1  Dick   21\r\n    Name  Age\r\n1   Dick   21\r\n2  Harry   19<\/pre>\n<\/div>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 640px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">DataFrame attributes and methods<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 240px;\" scope=\"col\">Name<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">What it gives<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">T<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The table flipped, so rows become columns<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">axes<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The row labels and the column labels<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">dtypes<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The data type of each column<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">empty<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">True if the table has no data<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">ndim<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The number of dimensions, 2 for a table<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">shape<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The number of rows and columns<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">size<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The number of cells<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">values<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The data as a NumPy array<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">head(n) and tail(n)<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">The first or last n rows<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">In pandas 3.0, the Name column shows the type <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">str<\/code>. Older versions showed <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">object<\/code>. We explain this at the end.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Descriptive Statistics in Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Here is a table of names, ages and ratings for 12 people. Twelve summary methods follow.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">stats = pd.DataFrame({\r\n    \"Name\": [\"Tomy\", \"Jimy\", \"Ricky\", \"Viny\", \"Steven\", \"Smithen\",\r\n             \"Jacky\", \"Lee\", \"Dravid\", \"Gaspery\", \"Betin\", \"Andru\"],\r\n    \"Age\": [22, 23, 26, 21, 30, 29, 23, 34, 40, 30, 51, 46],\r\n    \"Rating\": [5.23, 3.44, 3.95, 2.66, 4.20, 4.6, 6.8, 1.78, 3.98, 4.80, 4.10, 3.65],\r\n})\r\nprint(stats.head())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">     Name  Age  Rating\r\n0    Tomy   22    5.23\r\n1    Jimy   23    3.44\r\n2   Ricky   26    3.95\r\n3    Viny   21    2.66\r\n4  Steven   30    4.20<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Many of these methods work only on numbers. On a table with a text column, they give an error on current pandas:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">stats.mean()<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">TypeError: Cannot perform reduction 'mean' with string dtype<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">There are two fixes. Pick the number columns first, or use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">numeric_only=True<\/code>. Here are the twelve methods on the number columns:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">num = stats[[\"Age\", \"Rating\"]]\r\nprint(num.count())\r\nprint(num.sum())\r\nprint(num.mean())\r\nprint(num.median())\r\nprint(num.mode())\r\nprint(num.std().round(3))\r\nprint(num.min())\r\nprint(num.max())\r\nprint(num.prod())\r\nprint(num.cumsum().head(3))\r\nprint(num.cumprod().head(3))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">Age       12\r\nRating    12\r\ndtype: int64\r\nAge       375.00\r\nRating     49.19\r\ndtype: float64\r\nAge       31.250000\r\nRating     4.099167\r\ndtype: float64\r\nAge       29.50\r\nRating     4.04\r\ndtype: float64\r\n     Age  Rating\r\n0   23.0    1.78\r\n1   30.0    2.66\r\n2    NaN    3.44\r\n3    NaN    3.65\r\n4    NaN    3.95\r\n5    NaN    3.98\r\n6    NaN    4.10\r\n7    NaN    4.20\r\n8    NaN    4.60\r\n9    NaN    4.80\r\n10   NaN    5.23\r\n11   NaN    6.80\r\nAge       9.790\r\nRating    1.259\r\ndtype: float64\r\nAge       21.00\r\nRating     1.78\r\ndtype: float64\r\nAge       51.0\r\nRating     6.8\r\ndtype: float64\r\nAge       5.291495e+17\r\nRating    1.263793e+07\r\ndtype: float64\r\n   Age  Rating\r\n0   22    5.23\r\n1   45    8.67\r\n2   71   12.62\r\n     Age    Rating\r\n0     22   5.23000\r\n1    506  17.99120\r\n2  13156  71.06524<\/pre>\n<\/div>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 640px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Summary methods<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 240px;\" scope=\"col\">Method<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">What it gives<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">count<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">How many values are not missing<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">sum<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The total<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">mean<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The average<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">median<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The middle value<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">mode<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The most common value. It can give more than one<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">std<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The standard deviation, a measure of spread<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">min and max<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The smallest and the largest value<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">prod<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The product of all values<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">cumsum and cumprod<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">The running total and the running product<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The method <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">abs<\/code> gives the absolute value, and it works on numbers only. Skip it for a table with text.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">For a quick summary of every number column, use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">describe<\/code>:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(stats.mean(numeric_only=True))\r\nprint(stats.describe().round(2))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">Age       31.250000\r\nRating     4.099167\r\ndtype: float64\r\n         Age  Rating\r\ncount  12.00   12.00\r\nmean   31.25    4.10\r\nstd     9.79    1.26\r\nmin    21.00    1.78\r\n25%    23.00    3.60\r\n50%    29.50    4.04\r\n75%    35.50    4.65\r\nmax    51.00    6.80<\/pre>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Iterating Over a Pandas Table<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Iterating over a Series gives its values. Iterating over a DataFrame gives the column names. Loops over rows are usually slow, so use them only for small tables, or when you cannot do the job with a built in method. The three methods are <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">items<\/code>, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">iterrows<\/code> and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">itertuples<\/code>.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">items<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">This goes column by column. The older name <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">iteritems<\/code> was removed in pandas 2.0, and gives this error now:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">stats.iteritems()<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">AttributeError: 'DataFrame' object has no attribute 'iteritems'<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">items<\/code> instead:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">for col, values in stats.head(3).items():\r\n    print(col, list(values))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">Name ['Tomy', 'Jimy', 'Ricky']\r\nAge [22, 23, 26]\r\nRating [5.23, 3.44, 3.95]<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">iterrows<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">This goes row by row, and gives the index and the row. Mind the spelling, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">iterrows<\/code> with an s.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">for index, row in stats.head(3).iterrows():\r\n    print(index, row[\"Name\"], row[\"Age\"])<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">0 Tomy 22\r\n1 Jimy 23\r\n2 Ricky 26<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">itertuples<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">This is faster than <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">iterrows<\/code>, and gives each row as a named tuple.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">for row in stats.head(3).itertuples():\r\n    print(row)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">Pandas(Index=0, Name='Tomy', Age=22, Rating=5.23)\r\nPandas(Index=1, Name='Jimy', Age=23, Rating=3.44)\r\nPandas(Index=2, Name='Ricky', Age=26, Rating=3.95)<\/pre>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Working With Text in Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pandas has string methods that work on a whole column at once. They sit behind the <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">str<\/code> accessor, and they skip missing values. Here is a Series with one missing value and one number in quotes:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">s = pd.Series([\"Tom\", \"Dick\", \"Harry\", \"Allen\", np.nan, \"6234\", \"SteveJobs\"])\r\nprint(s)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">0          Tom\r\n1         Dick\r\n2        Harry\r\n3        Allen\r\n4          NaN\r\n5         6234\r\n6    SteveJobs\r\ndtype: str<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Note the last line. In pandas 3.0 the type is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">str<\/code>. In older versions, you would see <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">object<\/code>. Now the common methods:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(s.str.lower().tolist())\r\nprint(s.str.upper().tolist())\r\nprint(s.str.len().tolist())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">['tom', 'dick', 'harry', 'allen', nan, '6234', 'stevejobs']\r\n['TOM', 'DICK', 'HARRY', 'ALLEN', nan, '6234', 'STEVEJOBS']\r\n[3.0, 4.0, 5.0, 5.0, nan, 4.0, 9.0]<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The missing value gives <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">NaN<\/code> in the length result, and stays missing in the case methods. A few more methods on a cleaner Series:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">t = pd.Series([\"  Tom \", \"Dick Smith\", \"harry@mail.com\"])\r\nprint(t.str.strip().tolist())\r\nprint(t.str.split(\" \").tolist())\r\nprint(t.str.contains(\"@\").tolist())\r\nprint(t.str.replace(\"@\", \"$\").tolist())\r\nprint(t.str.repeat(2).tolist())\r\nprint(t.str.count(\"i\").tolist())\r\nprint(t.str.startswith(\"D\").tolist())\r\nprint(t.str.endswith(\"m\").tolist())\r\nprint(t.str.find(\"a\").tolist())\r\nprint(t.str.swapcase().tolist())\r\nprint(t.str.islower().tolist())\r\nprint(pd.Series([\"6234\", \"abc\"]).str.isnumeric().tolist())\r\nprint(pd.Series([\"a\", \"b\", \"c\"]).str.cat(sep=\"-\"))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">['Tom', 'Dick Smith', 'harry@mail.com']\r\n[['', '', 'Tom', ''], ['Dick', 'Smith'], ['harry@mail.com']]\r\n[False, False, True]\r\n['  Tom ', 'Dick Smith', 'harry$mail.com']\r\n['  Tom   Tom ', 'Dick SmithDick Smith', 'harry@mail.comharry@mail.com']\r\n[0, 2, 1]\r\n[False, True, False]\r\n[False, False, True]\r\n[-1, -1, 1]\r\n['  tOM ', 'dICK sMITH', 'HARRY@MAIL.COM']\r\n[False, False, True]\r\n[True, False]\r\na-b-c<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A few points that trip up beginners:<\/p>\n<ul style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 24px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">contains<\/code> needs a pattern, such as <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">contains(\"@\")<\/code>.<\/li>\n<li style=\"margin: 0 0 8px;\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">swapcase<\/code> needs brackets, as in <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">swapcase()<\/code>. Without them you get the method, and not the result.<\/li>\n<li style=\"margin: 0 0 8px;\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">isupper<\/code> checks if the text is in capitals, and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">upper<\/code> changes it. They are not the same.<\/li>\n<li style=\"margin: 0 0 8px;\">The method is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">isnumeric<\/code>. A method called <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">numeric<\/code> does not exist.<\/li>\n<li style=\"margin: 0 0 8px;\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">cat<\/code> joins the items with the separator that you give. If you give none, it joins them with no space.<\/li>\n<\/ul>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The wrong name gives this error:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">s.str.numeric()<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">AttributeError: 'StringMethods' object has no attribute 'numeric'<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The method <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">get_dummies<\/code> turns a text column that has several tags in one cell into a table of ones and zeros. It needs a separator in the text, and does not work on free text. Here is an example with a vertical bar as the separator:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(pd.Series([\"a|b\", \"a\", \"b|c\"]).str.get_dummies())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   a  b  c\r\n0  1  1  0\r\n1  1  0  0\r\n2  0  1  1<\/pre>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Window Functions in Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Window functions smooth data, and make trends easier to see. They are common in time series, such as daily sales or prices. The number of rows must match the number of dates. If it does not, pandas stops with an error:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">np.random.seed(1)\r\npd.DataFrame(np.random.randn(10, 4), index=pd.date_range(\"2026-02-02\", periods=5), columns=[\"W\", \"X\", \"Y\", \"Z\"])<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">ValueError: Shape of passed values is (10, 4), indices imply (5, 4)<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Random numbers also change from one run to another unless you set a seed. Here the data is fixed, with 6 rows and 6 dates, so that you can match every number.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">dates = pd.date_range(\"2026-02-02\", periods=6)\r\nw = pd.DataFrame(\r\n    {\"W\": [10, 12, 11, 15, 14, 18], \"X\": [5, 6, 8, 7, 9, 10]},\r\n    index=dates,\r\n)\r\nprint(w)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">             W   X\r\n2026-02-02  10   5\r\n2026-02-03  12   6\r\n2026-02-04  11   8\r\n2026-02-05  15   7\r\n2026-02-06  14   9\r\n2026-02-07  18  10<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">rolling<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Rolling takes a moving window of a set size. With <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">window=4<\/code> each result is the mean of the current and the three rows before it, which is four values. The first three rows are <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">NaN<\/code>, because there are not yet four values.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(w.rolling(window=4).mean())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">               W    X\r\n2026-02-02   NaN  NaN\r\n2026-02-03   NaN  NaN\r\n2026-02-04   NaN  NaN\r\n2026-02-05  12.0  6.5\r\n2026-02-06  13.0  7.5\r\n2026-02-07  14.5  8.5<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Check the first number by hand. The mean of 10, 12, 11 and 15 is 12.0, which matches.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">expanding<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Expanding takes all rows from the start up to the current row. With <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">min_periods=3<\/code> it starts giving results at the third row.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(w.expanding(min_periods=3).mean().round(3))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">                 W      X\r\n2026-02-02     NaN    NaN\r\n2026-02-03     NaN    NaN\r\n2026-02-04  11.000  6.333\r\n2026-02-05  12.000  6.500\r\n2026-02-06  12.400  7.000\r\n2026-02-07  13.333  7.500<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Check the third row. The mean of 10, 12 and 11 is 11.0, which matches.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">ewm<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Ewm is the exponentially weighted mean. Recent rows get more weight than old ones. The setting <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">com=0.5<\/code> sets how fast the weight falls off.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(w.ewm(com=0.5).mean().round(3))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">                 W      X\r\n2026-02-02  10.000  5.000\r\n2026-02-03  11.500  5.750\r\n2026-02-04  11.154  7.308\r\n2026-02-05  13.750  7.100\r\n2026-02-06  13.917  8.372\r\n2026-02-07  16.643  9.459<\/pre>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Using SQL Style Queries in Pandas<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">If you know SQL, many pandas jobs will look familiar. To keep the code simple and make it run anywhere, here is a small table with the same columns as the well known tips dataset.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">tips = pd.DataFrame({\r\n    \"total_bill\": [16.99, 10.34, 21.01, 23.68, 24.59, 25.29, 8.77, 26.88],\r\n    \"tip\": [1.01, 1.66, 3.50, 3.31, 3.61, 4.71, 2.00, 3.12],\r\n    \"sex\": [\"Female\", \"Male\", \"Male\", \"Male\", \"Female\", \"Male\", \"Male\", \"Male\"],\r\n    \"smoker\": [\"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"Yes\"],\r\n    \"time\": [\"Dinner\", \"Dinner\", \"Dinner\", \"Lunch\", \"Dinner\", \"Lunch\", \"Dinner\", \"Dinner\"],\r\n})\r\nprint(tips.head())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   total_bill   tip     sex smoker    time\r\n0       16.99  1.01  Female     No  Dinner\r\n1       10.34  1.66    Male     No  Dinner\r\n2       21.01  3.50    Male     No  Dinner\r\n3       23.68  3.31    Male     No   Lunch\r\n4       24.59  3.61  Female     No  Dinner<\/pre>\n<\/div>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 640px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">SQL ideas and pandas code<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 240px;\" scope=\"col\">SQL idea<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Pandas code<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">SELECT columns<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">tips[[&#8220;total_bill&#8221;, &#8220;tip&#8221;]]<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">WHERE<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">tips[tips[&#8220;time&#8221;] == &#8220;Dinner&#8221;]<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">GROUP BY with COUNT<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">tips.groupby(&#8220;sex&#8221;).size()<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">TOP N rows<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">tips.nlargest(3, &#8220;tip&#8221;)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">SELECT<\/h3>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(tips[[\"total_bill\", \"tip\", \"smoker\", \"time\"]].head(5))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   total_bill   tip smoker    time\r\n0       16.99  1.01     No  Dinner\r\n1       10.34  1.66     No  Dinner\r\n2       21.01  3.50     No  Dinner\r\n3       23.68  3.31     No   Lunch\r\n4       24.59  3.61     No  Dinner<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">WHERE<\/h3>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(tips[tips[\"time\"] == \"Dinner\"].head(5))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   total_bill   tip     sex smoker    time\r\n0       16.99  1.01  Female     No  Dinner\r\n1       10.34  1.66    Male     No  Dinner\r\n2       21.01  3.50    Male     No  Dinner\r\n4       24.59  3.61  Female     No  Dinner\r\n6        8.77  2.00    Male     No  Dinner<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">GROUP BY<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">size<\/code> method counts the rows in each group, and the second line takes the mean of one column.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(tips.groupby(\"sex\").size())\r\nprint(tips.groupby(\"sex\")[\"tip\"].mean().round(2))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">sex\r\nFemale    2\r\nMale      6\r\ndtype: int64\r\nsex\r\nFemale    2.31\r\nMale      3.05\r\nName: tip, dtype: float64<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">TOP N<\/h3>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(tips.nlargest(3, \"tip\"))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   total_bill   tip     sex smoker    time\r\n5       25.29  4.71    Male     No   Lunch\r\n4       24.59  3.61  Female     No  Dinner\r\n2       21.01  3.50    Male     No  Dinner<\/pre>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Reading a CSV File<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">In real work, the table comes from a file. The method is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">read_csv<\/code>. Here the file text is held in memory, so that you can run it without a file. With a real file, pass its name, as in <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">pd.read_csv(\"marks.csv\")<\/code>.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">from io import StringIO\r\n\r\ncsv_text = \"name,marks\\nAsha,72\\nRavi,88\\nMeena,91\\n\"\r\nprint(pd.read_csv(StringIO(csv_text)))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">    name  marks\r\n0   Asha     72\r\n1   Ravi     88\r\n2  Meena     91<\/pre>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">SQL Joins in Pandas With merge<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The function <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">merge<\/code> joins two tables on a shared column, just like a SQL join. Here are two tables with five rows each, joined on <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">subject_id<\/code>.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">left = pd.DataFrame({\r\n    \"id\": [1, 2, 3, 4, 5],\r\n    \"Name\": [\"Ali\", \"Any\", \"Amen\", \"Arik\", \"Amy\"],\r\n    \"subject_id\": [\"sub1\", \"sub2\", \"sub4\", \"sub6\", \"sub5\"],\r\n})\r\nright = pd.DataFrame({\r\n    \"id\": [1, 2, 3, 4, 5],\r\n    \"Name\": [\"Bil\", \"Briany\", \"Bany\", \"Brycy\", \"Betten\"],\r\n    \"subject_id\": [\"sub2\", \"sub4\", \"sub3\", \"sub6\", \"sub5\"],\r\n})<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Inner Join<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Keeps only the rows that have a match in both tables.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(pd.merge(left, right, on=\"subject_id\", how=\"inner\"))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   id_x Name_x subject_id  id_y  Name_y\r\n0     2    Any       sub2     1     Bil\r\n1     3   Amen       sub4     2  Briany\r\n2     4   Arik       sub6     4   Brycy\r\n3     5    Amy       sub5     5  Betten<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Left Join<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Keeps every row of the left table. Where there is no match, the right side shows <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">NaN<\/code>.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(pd.merge(left, right, on=\"subject_id\", how=\"left\"))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   id_x Name_x subject_id  id_y  Name_y\r\n0     1    Ali       sub1   NaN     NaN\r\n1     2    Any       sub2   1.0     Bil\r\n2     3   Amen       sub4   2.0  Briany\r\n3     4   Arik       sub6   4.0   Brycy\r\n4     5    Amy       sub5   5.0  Betten<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Right Join<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Keeps every row of the right table.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(pd.merge(left, right, on=\"subject_id\", how=\"right\"))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   id_x Name_x subject_id  id_y  Name_y\r\n0   2.0    Any       sub2     1     Bil\r\n1   3.0   Amen       sub4     2  Briany\r\n2   NaN    NaN       sub3     3    Bany\r\n3   4.0   Arik       sub6     4   Brycy\r\n4   5.0    Amy       sub5     5  Betten<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Outer Join<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Keeps all rows from both tables.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(pd.merge(left, right, on=\"subject_id\", how=\"outer\"))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   id_x Name_x subject_id  id_y  Name_y\r\n0   1.0    Ali       sub1   NaN     NaN\r\n1   2.0    Any       sub2   1.0     Bil\r\n2   NaN    NaN       sub3   3.0    Bany\r\n3   3.0   Amen       sub4   2.0  Briany\r\n4   5.0    Amy       sub5   5.0  Betten\r\n5   4.0   Arik       sub6   4.0   Brycy<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Choosing Clear Suffixes<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Both tables have the columns <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">id<\/code> and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">Name<\/code>. Pandas keeps both, and adds <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">_x<\/code> and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">_y<\/code>, as you can see in the results above. You can choose clearer names with the <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">suffixes<\/code> argument:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(pd.merge(left, right, on=\"subject_id\", how=\"inner\",\r\n               suffixes=(\"_left\", \"_right\")))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   id_left Name_left subject_id  id_right Name_right\r\n0        2       Any       sub2         1        Bil\r\n1        3      Amen       sub4         2     Briany\r\n2        4      Arik       sub6         4      Brycy\r\n3        5       Amy       sub5         5     Betten<\/pre>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Handling Missing Data<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Real data always has gaps. Three methods cover most cases. <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">isna<\/code> finds the gaps, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">fillna<\/code> fills them, and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">dropna<\/code> removes the rows that have them.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">m = pd.DataFrame({\"name\": [\"Asha\", \"Ravi\", \"Meena\"], \"marks\": [72, None, 91]})\r\nprint(m.isna().sum())\r\nprint(m.fillna(0))\r\nprint(m.dropna())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">name     0\r\nmarks    1\r\ndtype: int64\r\n    name  marks\r\n0   Asha   72.0\r\n1   Ravi    0.0\r\n2  Meena   91.0\r\n    name  marks\r\n0   Asha   72.0\r\n2  Meena   91.0<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Fill with zero only when zero makes sense. For marks, a missing value is not a mark of zero, so dropping the row or filling with the mean may fit better. Decide by the meaning of the data.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">What Changed in Pandas 3.0<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Pandas 3.0 came out in January 2026, and the latest release at the time of writing is 3.0.6, from 17 September 2026. A lot of older tutorials were written before it. These are the changes that matter to beginners, as listed in the official release notes.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">A Dedicated String Type<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A column of text now has the type <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">str<\/code>, and not <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">object<\/code>. The release notes say it can hold only strings or missing values.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(pd.Series([\"a\", \"b\"]).dtype)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">str<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Copy on Write<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The result of an indexing operation now always behaves as if it were a copy. Changing one never changes another. The release notes say chained assignment stops working, and the <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">SettingWithCopyWarning<\/code> is removed.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = pd.DataFrame({\"a\": [1, 2, 3]})\r\ny = x[\"a\"]\r\ny.iloc[0] = 99\r\nprint(x[\"a\"].tolist())\r\nprint(y.tolist())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">[1, 2, 3]\r\n[99, 2, 3]<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The table <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x<\/code> stayed the same when the new Series <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">y<\/code> changed. In older pandas, this could change both, which caused many silent bugs. If you wrote code such as <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">df[\"a\"][mask] = value<\/code>, replace it with the <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">loc<\/code> form:<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">z = pd.DataFrame({\"a\": [1, 2, 3], \"b\": [10, 20, 30]})\r\nz.loc[z[\"a\"] &gt; 1, \"b\"] = 0\r\nprint(z)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">   a   b\r\n0  1  10\r\n1  2   0\r\n2  3   0<\/pre>\n<\/div>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Other Changes to Know<\/h3>\n<ul style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 24px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">Python 3.11 or higher is needed, with NumPy 1.26 or higher.<\/li>\n<li style=\"margin: 0 0 8px;\">Strings now convert to dates at a finer unit than before, so the results of <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">to_datetime<\/code> can have a different type. Be careful when you turn dates into integers, because the numbers can be 1000 times smaller.<\/li>\n<li style=\"margin: 0 0 8px;\">The release notes advise upgrading to pandas 2.3 first, fixing the warnings, and only then moving to 3.0.<\/li>\n<\/ul>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">This list is not complete. For a project at work, read the full release notes before you upgrade.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Common Pandas Errors and How to Fix Them<\/h2>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 1000px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Pandas errors and fixes<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 380px;\" scope=\"col\">Error<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Usual cause<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">SyntaxError on print df<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Python 2 style print<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Write print(df)<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">SyntaxError on a curly quote<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Code copied from a web page or a Word file<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Type straight quotes in your editor<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">NameError: name pd is not defined<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The import uses another name<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Use import pandas as pd<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">ValueError: If using all scalar values, you must pass an index<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">A dictionary of single values<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Use lists as values, or pass an index<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">ValueError: Shape of passed values<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">More rows of data than index labels<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Make the index the same length as the data<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">TypeError: Cannot perform reduction mean with string dtype<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">A number method on a text column<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Select the number columns, or use numeric_only=True<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">AttributeError: no attribute iteritems<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">A method removed in pandas 2.0<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Use items<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">AttributeError: module pandas has no attribute Panel<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Panel was removed<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Use a DataFrame with a MultiIndex<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">AttributeError: dict has no attribute T<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">A dictionary used as a table<\/td>\n<td style=\"padding: 12px 16px; vertical-align: top;\">Wrap it with pd.DataFrame<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Practice Exercises<\/h2>\n<ol style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 28px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">Build a DataFrame of five students with a name, a course and marks. Print the average mark per course with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">groupby<\/code>.<\/li>\n<li style=\"margin: 0 0 8px;\">Add a column called <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">grade<\/code>. Give Pass if marks are 70 or more, and Needs work if not. Use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">np.where<\/code>.<\/li>\n<li style=\"margin: 0 0 8px;\">Add one missing mark and fill it with the mean of the column.<\/li>\n<li style=\"margin: 0 0 8px;\">Build a second table of courses and their teachers, and merge it with the first on the course name. Try an inner and a left join.<\/li>\n<li style=\"margin: 0 0 8px;\">Make a column of daily sales for 10 days, and compute a 3 day rolling mean.<\/li>\n<\/ol>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Complete Script to Run Yourself<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Here is the full script that was used to test every example on this page. It ran on pandas 3.0.5 and NumPy 2.5.3. The blocks that show an error are written to fail on purpose, so run those one at a time, or wrap them in <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">try<\/code> and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">except<\/code>.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\"># ver\r\nimport pandas as pd\r\nimport numpy as np\r\n\r\nprint(pd.__version__)\r\n\r\n# s_list\r\nmarks = pd.Series([72, 88, 91, 65])\r\nprint(marks)\r\n\r\n# s_idx\r\nmarks = pd.Series([72, 88, 91, 65], index=[\"Asha\", \"Ravi\", \"Meena\", \"Kabir\"])\r\nprint(marks)\r\nprint(marks[\"Ravi\"])\r\nprint(marks.iloc[2])\r\n\r\n# s_arr\r\na = np.array([1, 4, 5, 6, 7])\r\ns = pd.Series(a)\r\nprint(s)\r\n\r\n# s_dict\r\nd = {\"a\": \"add\", \"s\": \"sub\", \"d\": \"dvd\"}\r\ns = pd.Series(d)\r\nprint(s)\r\n\r\n# s_const\r\ns = pd.Series(4, index=[0, 1, 2])\r\nprint(s)\r\n\r\n# s_pos\r\ns = pd.Series([1, 4, 5, 6, 7])\r\nprint(s[2])\r\nprint(s.iloc[2])\r\n\r\n# df_list\r\ndata = [9, 2, 3, 4, 5]\r\ndf1 = pd.DataFrame(data, columns=[\"value\"])\r\nprint(df1)\r\n\r\n# df_dict_err\r\npd.DataFrame({\"a\": \"add\", \"s\": \"sub\", \"d\": \"dvd\"})\r\n\r\n# df_dict\r\ndf = pd.DataFrame({\r\n    \"name\": [\"Asha\", \"Ravi\", \"Meena\", \"Kabir\"],\r\n    \"course\": [\"Python\", \"SQL\", \"Python\", \"Excel\"],\r\n    \"marks\": [72, 88, 91, 65],\r\n})\r\nprint(df)\r\n\r\n# df_rows\r\nrows = [\r\n    {\"name\": \"Asha\", \"marks\": 72},\r\n    {\"name\": \"Ravi\", \"marks\": 88},\r\n]\r\nprint(pd.DataFrame(rows))\r\n\r\n# df_series\r\nd = {\r\n    \"one\": pd.Series([2, 3, 4], index=[\"a\", \"b\", \"c\"]),\r\n    \"two\": pd.Series([2, 3, 4, 5], index=[\"a\", \"b\", \"c\", \"d\"]),\r\n}\r\ndfs = pd.DataFrame(d)\r\nprint(dfs)\r\n\r\n# df_arr\r\narr = np.array([[1, 2, 3], [4, 5, 6]])\r\nprint(pd.DataFrame(arr, columns=[\"x\", \"y\", \"z\"]))\r\n\r\n# df_copy\r\ncopy_df = pd.DataFrame(df)\r\nprint(copy_df.equals(df))\r\n\r\n# col_add\r\ndfs[\"three\"] = pd.Series([100, 200, 300], index=[\"a\", \"b\", \"c\"])\r\nprint(dfs)\r\ndfs[\"four\"] = dfs[\"one\"] + dfs[\"three\"]\r\nprint(dfs)\r\n\r\n# col_del\r\ndel dfs[\"one\"]\r\nprint(dfs)\r\npopped = dfs.pop(\"two\")\r\nprint(popped)\r\nprint(dfs)\r\nprint(dfs.drop(columns=[\"four\"]))\r\n\r\n# ser_attr\r\ns = pd.Series([10, 20, 30, 40, 50, 60, 70, 80, 90])\r\nprint(s.axes)\r\nprint(s.empty)\r\nprint(s.ndim)\r\nprint(s.size)\r\nprint(s.values)\r\nprint(s.head(3))\r\nprint(s.tail(3))\r\n\r\n# df_attr\r\ndata = {\"Name\": [\"Tom\", \"Dick\", \"Harry\"], \"Age\": [20, 21, 19]}\r\npeople = pd.DataFrame(data)\r\nprint(people.T)\r\nprint(people.axes)\r\nprint(people.dtypes)\r\nprint(people.empty)\r\nprint(people.ndim)\r\nprint(people.shape)\r\nprint(people.size)\r\nprint(people.values)\r\nprint(people.head(2))\r\nprint(people.tail(2))\r\n\r\n# dict_err\r\ndata = {\"Name\": [\"Tom\", \"Dick\", \"Harry\"], \"Age\": [20, 21, 19]}\r\ndata.T\r\n\r\n# stats_setup\r\nstats = pd.DataFrame({\r\n    \"Name\": [\"Tomy\", \"Jimy\", \"Ricky\", \"Viny\", \"Steven\", \"Smithen\",\r\n             \"Jacky\", \"Lee\", \"Dravid\", \"Gaspery\", \"Betin\", \"Andru\"],\r\n    \"Age\": [22, 23, 26, 21, 30, 29, 23, 34, 40, 30, 51, 46],\r\n    \"Rating\": [5.23, 3.44, 3.95, 2.66, 4.20, 4.6, 6.8, 1.78, 3.98, 4.80, 4.10, 3.65],\r\n})\r\nprint(stats.head())\r\n\r\n# stats_all\r\nnum = stats[[\"Age\", \"Rating\"]]\r\nprint(num.count())\r\nprint(num.sum())\r\nprint(num.mean())\r\nprint(num.median())\r\nprint(num.mode())\r\nprint(num.std().round(3))\r\nprint(num.min())\r\nprint(num.max())\r\nprint(num.prod())\r\nprint(num.cumsum().head(3))\r\nprint(num.cumprod().head(3))\r\n\r\n# stats_err\r\nstats.mean()\r\n\r\n# stats_ok\r\nprint(stats.mean(numeric_only=True))\r\nprint(stats.describe().round(2))\r\n\r\n# iter_items\r\nfor col, values in stats.head(3).items():\r\n    print(col, list(values))\r\n\r\n# iter_rows\r\nfor index, row in stats.head(3).iterrows():\r\n    print(index, row[\"Name\"], row[\"Age\"])\r\n\r\n# iter_tuples\r\nfor row in stats.head(3).itertuples():\r\n    print(row)\r\n\r\n# iter_err\r\nstats.iteritems()\r\n\r\n# str_setup\r\ns = pd.Series([\"Tom\", \"Dick\", \"Harry\", \"Allen\", np.nan, \"6234\", \"SteveJobs\"])\r\nprint(s)\r\n\r\n# str_basic\r\nprint(s.str.lower().tolist())\r\nprint(s.str.upper().tolist())\r\nprint(s.str.len().tolist())\r\n\r\n# str_more\r\nt = pd.Series([\"  Tom \", \"Dick Smith\", \"harry@mail.com\"])\r\nprint(t.str.strip().tolist())\r\nprint(t.str.split(\" \").tolist())\r\nprint(t.str.contains(\"@\").tolist())\r\nprint(t.str.replace(\"@\", \"$\").tolist())\r\nprint(t.str.repeat(2).tolist())\r\nprint(t.str.count(\"i\").tolist())\r\nprint(t.str.startswith(\"D\").tolist())\r\nprint(t.str.endswith(\"m\").tolist())\r\nprint(t.str.find(\"a\").tolist())\r\nprint(t.str.swapcase().tolist())\r\nprint(t.str.islower().tolist())\r\nprint(pd.Series([\"6234\", \"abc\"]).str.isnumeric().tolist())\r\nprint(pd.Series([\"a\", \"b\", \"c\"]).str.cat(sep=\"-\"))\r\n\r\n# str_dummies\r\nprint(pd.Series([\"a|b\", \"a\", \"b|c\"]).str.get_dummies())\r\n\r\n# str_err\r\ns.str.numeric()\r\n\r\n# win_setup\r\ndates = pd.date_range(\"2026-02-02\", periods=6)\r\nw = pd.DataFrame(\r\n    {\"W\": [10, 12, 11, 15, 14, 18], \"X\": [5, 6, 8, 7, 9, 10]},\r\n    index=dates,\r\n)\r\nprint(w)\r\n\r\n# rolling\r\nprint(w.rolling(window=4).mean())\r\n\r\n# expanding\r\nprint(w.expanding(min_periods=3).mean().round(3))\r\n\r\n# ewm\r\nprint(w.ewm(com=0.5).mean().round(3))\r\n\r\n# win_err\r\nnp.random.seed(1)\r\npd.DataFrame(np.random.randn(10, 4), index=pd.date_range(\"2026-02-02\", periods=5), columns=[\"W\", \"X\", \"Y\", \"Z\"])\r\n\r\n# sql_setup\r\ntips = pd.DataFrame({\r\n    \"total_bill\": [16.99, 10.34, 21.01, 23.68, 24.59, 25.29, 8.77, 26.88],\r\n    \"tip\": [1.01, 1.66, 3.50, 3.31, 3.61, 4.71, 2.00, 3.12],\r\n    \"sex\": [\"Female\", \"Male\", \"Male\", \"Male\", \"Female\", \"Male\", \"Male\", \"Male\"],\r\n    \"smoker\": [\"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"Yes\"],\r\n    \"time\": [\"Dinner\", \"Dinner\", \"Dinner\", \"Lunch\", \"Dinner\", \"Lunch\", \"Dinner\", \"Dinner\"],\r\n})\r\nprint(tips.head())\r\n\r\n# sql_select\r\nprint(tips[[\"total_bill\", \"tip\", \"smoker\", \"time\"]].head(5))\r\n\r\n# sql_where\r\nprint(tips[tips[\"time\"] == \"Dinner\"].head(5))\r\n\r\n# sql_group\r\nprint(tips.groupby(\"sex\").size())\r\nprint(tips.groupby(\"sex\")[\"tip\"].mean().round(2))\r\n\r\n# sql_top\r\nprint(tips.nlargest(3, \"tip\"))\r\n\r\n# sql_csv\r\nfrom io import StringIO\r\n\r\ncsv_text = \"name,marks\\nAsha,72\\nRavi,88\\nMeena,91\\n\"\r\nprint(pd.read_csv(StringIO(csv_text)))\r\n\r\n# join_setup\r\nleft = pd.DataFrame({\r\n    \"id\": [1, 2, 3, 4, 5],\r\n    \"Name\": [\"Ali\", \"Any\", \"Amen\", \"Arik\", \"Amy\"],\r\n    \"subject_id\": [\"sub1\", \"sub2\", \"sub4\", \"sub6\", \"sub5\"],\r\n})\r\nright = pd.DataFrame({\r\n    \"id\": [1, 2, 3, 4, 5],\r\n    \"Name\": [\"Bil\", \"Briany\", \"Bany\", \"Brycy\", \"Betten\"],\r\n    \"subject_id\": [\"sub2\", \"sub4\", \"sub3\", \"sub6\", \"sub5\"],\r\n})\r\n\r\n# join_left\r\nprint(pd.merge(left, right, on=\"subject_id\", how=\"left\"))\r\n\r\n# join_right\r\nprint(pd.merge(left, right, on=\"subject_id\", how=\"right\"))\r\n\r\n# join_outer\r\nprint(pd.merge(left, right, on=\"subject_id\", how=\"outer\"))\r\n\r\n# join_inner\r\nprint(pd.merge(left, right, on=\"subject_id\", how=\"inner\"))\r\n\r\n# join_suffix\r\nprint(pd.merge(left, right, on=\"subject_id\", how=\"inner\",\r\n               suffixes=(\"_left\", \"_right\")))\r\n\r\n# panel_err\r\npd.Panel(np.random.rand(2, 3, 4))\r\n\r\n# missing\r\nm = pd.DataFrame({\"name\": [\"Asha\", \"Ravi\", \"Meena\"], \"marks\": [72, None, 91]})\r\nprint(m.isna().sum())\r\nprint(m.fillna(0))\r\nprint(m.dropna())\r\n\r\n# str_dtype\r\nprint(pd.Series([\"a\", \"b\"]).dtype)\r\n\r\n# cow\r\nx = pd.DataFrame({\"a\": [1, 2, 3]})\r\ny = x[\"a\"]\r\ny.iloc[0] = 99\r\nprint(x[\"a\"].tolist())\r\nprint(y.tolist())\r\n\r\n# chain_fix\r\nz = pd.DataFrame({\"a\": [1, 2, 3], \"b\": [10, 20, 30]})\r\nz.loc[z[\"a\"] &gt; 1, \"b\"] = 0\r\nprint(z)<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Python Pandas Tutorial for Beginners: Series, DataFrames and Real Examples A marks sheet, a sales report, a list of customers. Most of the data you meet at work sits in rows and columns. Pandas is the Python library that handles such tables the way a spreadsheet would, but with code that you can repeat, test [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3337,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,1673],"tags":[361,72],"class_list":["post-2706","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-python-pandas","tag-python-pandas-tutorial-for-beginners","tag-python-pandas-tutorials"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Pandas Tutorial for Beginners: Series and DataFrames<\/title>\n<meta name=\"description\" content=\"Learn pandas in Python with tested examples: install, Series, DataFrames, statistics, merge, groupby, missing data, and what changed in pandas 3.0.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Pandas Tutorial for Beginners: Series and DataFrames\" \/>\n<meta property=\"og:description\" content=\"Learn pandas in Python with tested examples: install, Series, DataFrames, statistics, merge, groupby, missing data, and what changed in pandas 3.0.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-21T13:53:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-22T02:44:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"550\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/\",\"url\":\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/\",\"name\":\"Python Pandas Tutorial for Beginners: Series and DataFrames\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg\",\"datePublished\":\"2026-10-21T13:53:59+00:00\",\"dateModified\":\"2026-10-22T02:44:24+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Learn pandas in Python with tested examples: install, Series, DataFrames, statistics, merge, groupby, missing data, and what changed in pandas 3.0.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg\",\"width\":960,\"height\":550,\"caption\":\"Python Pandas Tutorials\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Pandas Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Pandas Tutorial for Beginners: Series and DataFrames","description":"Learn pandas in Python with tested examples: install, Series, DataFrames, statistics, merge, groupby, missing data, and what changed in pandas 3.0.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/","og_locale":"en_US","og_type":"article","og_title":"Python Pandas Tutorial for Beginners: Series and DataFrames","og_description":"Learn pandas in Python with tested examples: install, Series, DataFrames, statistics, merge, groupby, missing data, and what changed in pandas 3.0.","og_url":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2026-10-21T13:53:59+00:00","article_modified_time":"2026-10-22T02:44:24+00:00","og_image":[{"width":960,"height":550,"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg","type":"image\/jpeg"}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/","url":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/","name":"Python Pandas Tutorial for Beginners: Series and DataFrames","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg","datePublished":"2026-10-21T13:53:59+00:00","dateModified":"2026-10-22T02:44:24+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Learn pandas in Python with tested examples: install, Series, DataFrames, statistics, merge, groupby, missing data, and what changed in pandas 3.0.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/08\/Python-Pandas-Tutorials.jpg","width":960,"height":550,"caption":"Python Pandas Tutorials"},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/python\/python-pandas\/python-pandas-tutorial-for-beginners\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Pandas Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=2706"}],"version-history":[{"count":20,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2706\/revisions"}],"predecessor-version":[{"id":12079,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2706\/revisions\/12079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media\/3337"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=2706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=2706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=2706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}