1. Home
  2. Explore
  3. Computer Science
  4. Data Analysis with Python

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Data Analysis with Python

Speaker 1Speaker 2

Data Analysis with Python

27:37
0:00-27:37
  1. Maria

    Welcome to our data analysis with Python episode. We’ll follow the path of a typical analysis: getting data, cleaning and reshaping it, finding patterns, and communicating what we learn. Along the way, we’ll meet the main tools in the Python data stack, including NumPy, pandas, Matplotlib, and Seaborn.

  2. Michael

    And this is useful whether you’re new to Python or coming from tools like Excel and Tableau. The tutorial we’re drawing from is a free collaboration between freeCodeCamp and Remoter, with notebooks, slides, and exercises. Its sections include a quick demonstration, detailed tool lessons, an optional Jupyter introduction, and a short Python recap for people coming from other programming languages.

  3. Maria

    Let’s begin with the central definition: data analysis is the process of inspecting, cleansing, transforming, and modeling data to discover useful information, draw conclusions, and support decisions. Each verb matters. We don’t simply collect numbers; we prepare them, investigate them, and turn the results into something people can use.

  4. Michael

    The first stage can be the least glamorous: gathering and cleaning data, then transforming it so it’s suitable for analysis. Data might come from a database, a CSV or Excel file, or a web API. Pandas is one of the main tools for reading and reshaping that data.

  5. Maria

    Modeling means representing real-world situations in a form we can analyze, including looking for patterns with statistical methods. Pandas provides tools for working with data and statistics; Matplotlib and Seaborn help us visualize what we find. Those views can help reveal trends, relationships, and anomalies.

  6. Michael

    The aim is to turn data into information. A huge list of purchases is data; a finding such as “Pop-Tarts sell better on Tuesdays” is information. Then we need evidence and a readable report or dashboard so other people can act on the finding.

  7. Maria

    Those people may work in marketing, sales, accounting, or leadership, and they won’t all need the same view. One audience may want a high-level summary, while another needs more detail. Communicating the analysis is part of the work, not an afterthought.

  8. Michael

    The tutorial divides analysis tools into managed, or closed, products and open programming tools. Excel and Tableau are examples of managed products: they’re ready to use and generally easier to learn, with a vendor providing documentation and support. Their limitation is that you’re working within the product’s scope.

  9. Maria

    Programming languages such as Python, R, and Julia offer a different trade-off. They take longer to learn because you first need coding fundamentals, but they give you much more flexibility. The tutorial’s examples include connecting to an API that requires a secret key or consuming data from AWS Kinesis.

  10. Michael

    That flexibility can matter for a career, too. Skills in processing data with a programming language can transfer beyond a particular product, rather than tying your work to one interface. The tutorial also cites a PayScale comparison suggesting analysts who know Python and SQL are better paid than those who don’t know programming tools.

  11. Maria

    Why choose Python? The tutorial describes it as readable and approachable, free and open source, and supported by thousands of libraries for many kinds of work. It’s used by major organizations, has extensive documentation and free learning resources, and has an active developer community.

  12. Michael

    R deserves a mention as well. It has a huge library of statistical functions and can be a good choice in highly technical disciplines. The tutorial favors Python for getting started and for the breadth of general-purpose libraries and tools it offers.

  13. Maria

    A useful process map is: collect, clean, reshape, analyze, and communicate. Cleaning can be relatively straightforward when data comes from a well-maintained database, and more laborious when it comes from sources such as web scraping. Reshaping might mean changing fields, merging tables, or combining sources.

  14. Michael

    Analysis then looks for patterns, trends, or anomalies in the prepared data, often with statistical methods. What happens next depends on the goal: a data science project might move toward machine learning, while a data analysis project might produce reports to support decisions. And in real work, this is a cycle—we often return to earlier steps.

  15. Maria

    The boundary between data analysis and data science isn’t perfectly clear. In the tutorial’s comparison, data scientists tend to bring more programming and mathematics skills and may apply them to machine learning or ETL processes. Analysts are described as especially strong at communication, reporting, and storytelling.

  16. Michael

    The Python data ecosystem has many specialized libraries, but pandas is central for data analysis, with Matplotlib and Seaborn prominent for visualization. NumPy underlies much of the numerical work. Other libraries can serve particular use cases, so the ecosystem is larger than a single list of tools.

  17. Maria

    There’s also a change in how you think about the data. In Excel or Tableau, you often have a visual reference in front of you, which can work well for smaller data. But as the number of records grows, inspecting everything visually becomes impractical and slow.

  18. Michael

    With Python, you don’t keep looking at every row. You build an understanding of the data’s structure and statistical properties, then use summaries and targeted views to ask questions. That approach can handle very large datasets and makes it easier to move analysis from one computer to another, including to the cloud.

  19. Maria

    Let’s make that concrete with the tutorial’s sales-data demonstration. The first step is reading a CSV into pandas, which can be done in a single line. The resulting DataFrame is a table-like structure with rows and columns, and each column has a data type.

  20. Michael

    Before inspecting individual records, check the DataFrame’s shape to learn its number of rows and columns, and use an information summary to inspect column names, types, and non-missing counts. A statistical description gives quick summaries for numeric columns. That provides a useful map of the data without scrolling through every row.

  21. Maria

    For example, the demonstration checked customer age and found an average around 35, a minimum of 17, and a maximum of 87. Comparing the median with the mean can help you form an initial impression of the distribution. Unusually large values or negative profit values are prompts to investigate, not automatic proof of an error.

  22. Michael

    You can focus on a single column, such as unit cost, and summarize or visualize just that field. A box plot shows the median, quartiles, whiskers, and potential outliers; a density plot or histogram gives another view of the distribution. The point is to use summaries and plots to guide questions about the data.

  23. Maria

    Categorical columns can be explored with value counts. The sales example groups customers into categories such as seniors, youth, young adults, and adults, then compares their counts with a bar or pie chart. In that particular dataset, adults were the largest group.

  24. Michael

    Correlation analysis gives a quick view of how numeric variables move together. The example examined profit, unit cost, unit price, revenue, and order quantity, then used a correlation matrix and scatter plots to inspect relationships. A strong correlation is a clue to investigate; it doesn’t, by itself, explain why two variables are related.

  25. Maria

    You can also compare distributions across groups, such as profit by customer age group, using box plots. And you can create derived columns from existing ones. The example calculates revenue per age and total calculated cost by multiplying order quantity by unit cost.

  26. Michael

    Derived values can also be used to check data quality. The demonstration compares calculated cost with the supplied cost and asks whether any rows disagree. It also shows how quickly Python can apply a calculation across many records, compared with manually extending a spreadsheet formula.

  27. Maria

    Filtering is another everyday operation: select sales from Kentucky, restrict the data to a customer group or country, and calculate an average revenue for that subset. You can also update values, such as applying a price increase. The examples are demonstrations of the operation, not recommendations to change prices arbitrarily.

  28. Michael

    The same general workflow works when the source is a SQL database rather than a CSV. You write a query to retrieve the records, use a database connector, and bring the result into a pandas DataFrame. The tutorial uses MySQL in one example and also demonstrates SQLite; connectors are available for databases such as PostgreSQL, Oracle, and SQL Server.

  29. Maria

    Once the query result is in a DataFrame, the analysis steps are familiar: inspect its shape and columns, review data types and summary statistics, filter records, create new columns, and visualize results. In the film-rental example, the analysis examines rental rates, city counts, and a simple measure comparing rental revenue with replacement cost.

  30. Michael

    The database example also demonstrates zooming in on records—for instance, filtering by a customer name, replacement cost, or film rating. That kind of selection lets you investigate a specific part of the data without abandoning the broader process of cleaning, reshaping, combining, and visualizing.

  31. Maria

    A key working environment in the tutorial is Jupyter. Jupyter is an open-source ecosystem, and a notebook is an interactive place to run code and explore data. JupyterLab builds on the notebook experience with a richer interface, including a file tree, terminals, previews, and other tools.

  32. Michael

    A notebook is made of cells. A cell can contain code, or Markdown, a lightweight format for headings, bold text, links, and other document formatting. Mixing code and explanations makes it possible to create a readable analysis, and notebooks can be exported as formats such as HTML or PDF.

  33. Maria

    A code cell runs in a Python interpreter and returns results interactively. That makes it useful for learning Python as well as exploring data. Visualizations can appear right in the notebook, so you don’t need to move between a separate terminal and a separate charting application.

  34. Michael

    Jupyter has two important modes. In edit mode, the cell is active for typing; press Escape to leave edit mode and enter command mode, where keyboard shortcuts operate on the cell. Press Enter to return to editing. This distinction is essential because the same key can type a character in edit mode but perform a command in command mode.

  35. Maria

    In command mode, A inserts a cell above and B inserts one below; pressing D twice deletes a cell, and Z undoes an action. M changes a cell to Markdown and Y changes it back to code. The tutorial recommends learning keyboard shortcuts gradually and using the command palette or toolbar when you can’t remember one.

  36. Michael

    To run a cell and keep it selected, use Control-Enter; Shift-Enter runs it and moves to the next cell. Each execution receives a count, which records execution order even if you later move cells around. That’s a helpful reminder that the order in which cells were run may differ from their order on the page.

  37. Maria

    The tutorial also demonstrates getting data from a public API inside a notebook. It requests historical cryptocurrency prices and works with open, high, low, and close values, as well as volume. A simple plot then reveals how prices changed over the selected period.

  38. Michael

    Matplotlib charts are typically static images, which are useful for reports and exports. Bokeh is shown as an option for interactive charts that let you zoom and explore the data. The tutorial favors Matplotlib in many examples because it’s widely used and works closely with pandas and Seaborn.

  39. Maria

    Now for NumPy, the numerical-computing library that supports much of this ecosystem. Its focus is arrays and numerical operations. You may not call NumPy directly in every analysis, because libraries such as pandas and Matplotlib use it underneath, but understanding its arrays helps explain how those tools work.

  40. Michael

    The tutorial gives a low-level reason NumPy can be efficient. Computers represent information in bits, and the number of bits used affects how much memory a value takes. If you know a column has a limited range—ages are a simple example—you may not need an unnecessarily large numeric representation.

  41. Maria

    Ordinary Python numbers are flexible objects, which makes them convenient but can add memory overhead. NumPy lets you work with typed arrays and specify numeric types such as different integer widths. Its arrays store values in a structured way and can take advantage of optimized numerical operations.

  42. Michael

    You don’t need to master binary arithmetic before using NumPy. The practical message is to start with its defaults, then think about numeric types when memory or performance becomes a bottleneck. The tutorial’s low-level discussion is there to explain why the library matters, not to make that a prerequisite.

  43. Maria

    A NumPy array can be created from a Python list, and you access or slice its elements much like a list, including negative indices. You can also select several positions at once by passing a list of indices. Unlike a regular list, a NumPy array has a consistent data type.

  44. Michael

    Arrays can have more than one dimension. A two-dimensional array is like a matrix with rows and columns; adding another dimension gives you a three-dimensional structure. Attributes such as shape, number of dimensions, and total size help you understand the structure.

  45. Maria

    Indexing a matrix means specifying positions across its dimensions. You can select a particular row and column, or use slices to take ranges. When creating a multidimensional array, the dimensions need to be consistent; mismatched nested sequences can produce an unintended object-type structure rather than the regular array you meant to create.

  46. Michael

    NumPy also supplies common calculations such as sum, mean, standard deviation, and variance. For a multidimensional array, you can calculate across an axis—for example, down columns or across rows. Knowing which axis you mean is the key to interpreting the result.

  47. Maria

    One of NumPy’s most useful ideas is vectorized operations. Instead of writing a loop to add ten to every element, you can express the operation on the whole array. NumPy applies it across the elements efficiently, and, by default, the operation returns a new array rather than changing the original.

  48. Michael

    Compatible arrays can also be combined element by element. Broadcasting extends this idea to operations between an array and a scalar, such as multiplying every element by ten. It can also apply when array shapes are compatible, but you do need to respect those shape rules.

  49. Maria

    Boolean arrays make filtering possible. A comparison such as “array greater than or equal to two” produces a true-or-false result for each element. Use that Boolean result to select the values that meet the condition, instead of writing out a separate decision for every record.

  50. Michael

    You can combine conditions with logical operators and use the resulting Boolean array to make more precise selections. This becomes especially useful in pandas, where the same idea lets you ask for rows matching conditions on columns. NumPy also includes operations used in linear algebra, such as matrix-related calculations.

  51. Maria

    The tutorial illustrates the performance difference between Python lists and NumPy arrays by applying a calculation to many numbers. The NumPy version is faster in the demonstration, particularly as the amount of data grows. For data analysis, this efficient numerical foundation is one reason NumPy is so important.

  52. Michael

    Pandas is the main library in the tutorial for day-to-day data analysis. It helps read data from sources such as databases, CSVs, and Excel files, then clean, reshape, summarize, and visualize it. It can also work alongside other libraries for more advanced tasks.

  53. Maria

    Pandas has two main structures: Series and DataFrame. A Series is an ordered sequence of values backed by NumPy, with an index that identifies its entries. A DataFrame is a table of rows and columns, and each column can be understood as a Series.

  54. Michael

    A Series index can use meaningful labels instead of only positions. That means you can retrieve a country’s population by its country label rather than needing to remember where it appears in the sequence. The Series remains ordered, while its labels make access more expressive.

  55. Maria

    Series support selection by label and by position, as well as Boolean filtering. A comparison creates a Boolean Series, and you can use it to select values that meet a condition. Pandas also supports common numerical and statistical calculations through its NumPy foundation.

  56. Michael

    Pay special attention to slicing: in pandas label-based slices, the ending label is included. That differs from the usual Python slice behavior, where the upper bound is excluded. Also, Series operations generally produce a new result; to keep a change, assign that result where you want it.

  57. Maria

    A DataFrame adds another dimension: it has both row labels and named columns. Use its information summary to inspect columns, types, and missing-value counts; shape tells you the dimensions, and a statistical description summarizes numeric columns. These are excellent first checks after loading a dataset.

  58. Michael

    There are three useful selection patterns to remember. Use loc to select rows by label and iloc to select rows by position; selecting a column by its name gives you that column as a Series. You can combine row and column selection, and iloc follows Python’s usual exclusive upper bound for slices.

  59. Maria

    Boolean filtering works on DataFrames too. Create a condition from a column, then use it to select the rows that match; combine conditions when you need more than one rule. You can drop rows or columns, but remember that most pandas operations return a new object rather than modifying the original in place.

  60. Michael

    You can add a column by assigning a Series or a calculated result. Pandas aligns values by their index, which is why entries with matching labels land in the right rows. A calculation between columns, such as revenue divided by population, can create a new derived column efficiently.

  61. Maria

    Pandas also has an extensive set of statistical summaries, including minimum, maximum, mean, and median. The key structure relationship is that a DataFrame holds columns and rows, while operations may return a Series. You can then use that Series in another operation or assign it back as a DataFrame column.

  62. Michael

    Reading a CSV begins with read_csv, and pandas offers related functions for other formats, including Excel, SQL, HTML, and JSON. You can configure headers, column names, types, date parsing, missing-value markers, separators, and other details. The tutorial stresses that there are many options, so consulting the documentation for your particular file is normal.

  63. Maria

    For example, if a CSV has no header row, tell pandas not to infer one and provide the column names yourself. You can parse a timestamp column as dates and use it as the index, making it convenient to look up a record for a particular date. You can also inspect the first or last rows and the DataFrame information to check that the import worked.

  64. Michael

    Pandas can read a CSV from a local file or a remote location, and it has corresponding methods for writing data out. The tutorial uses plot methods on a DataFrame to make a quick chart, with Matplotlib providing the plotting machinery underneath. More specialized plotting details can be learned when you need them.

  65. Maria

    Data cleaning deserves its own careful process. The tutorial describes four broad concerns, starting with missing data and invalid values, then moving toward values that may be technically valid but inconsistent with the subject area. That last category can be the hardest because it requires knowing the domain.

  66. Michael

    A missing value might be handled by dropping a record, filling the gap with a value such as a mean, or investigating the source if the missing information is essential. Pandas provides isna and isnull, and their opposites, to identify missing values. These can be applied to individual data, Series, or DataFrames.

  67. Maria

    You can count missing values by summing the Boolean results, because true values contribute to the count. dropna removes missing values; on a DataFrame, its default behavior drops rows containing missing values, and options let you adjust the direction or require a threshold of valid entries. fillna can replace missing values with a constant or a calculated value.

  68. Michael

    Forward fill and backward fill propagate neighboring values through gaps, either across rows or down columns depending on the axis. They may leave gaps at an edge where there’s no value to propagate. As with many pandas operations, the result is generally a new object unless you explicitly assign it.

  69. Maria

    Invalid values are a different problem. A question mark in an age column, for example, is the wrong kind of value; value_counts can help reveal unexpected categories, and replace can correct them. But an age of 290 is different: it is a number, yet it is probably invalid for a human age, so resolving it requires judgment about the data’s domain.

  70. Michael

    Duplicates also depend on a definition. Pandas can identify repeated values and drop duplicates, with options controlling whether the first or last occurrence is retained—or whether all repeated occurrences count as duplicates. For a DataFrame, you can specify the columns that define a duplicate, because two records that differ in an important field may represent different cases.

  71. Maria

    String columns have methods available through the str accessor, just as date and categorical columns have their own specialized accessors. String operations include splitting, checking for contained text, stripping, and replacing; some can use regular expressions. Splitting with an option to expand can turn pieces of a string into separate columns.

  72. Michael

    Visualization helps with cleaning as well as explaining results. A histogram or box plot can show whether a value looks unusual, but deciding whether it is genuinely wrong depends on context. An age that is plausible in one population could be an outlier in a dataset limited to high-school students.

  73. Maria

    Matplotlib can be used through a global-style interface or an object-oriented interface. With the global style, successive commands affect the currently active plot, so the meaning of a line can depend on what ran before it. The object-oriented style keeps explicit references to figures and axes, which makes it clearer which plot each command changes.

  74. Michael

    Matplotlib supports many kinds of charts: line plots, scatter plots, histograms, density-style plots, bar charts, and box plots are among the examples. A scatter plot can encode additional information through color or marker size, letting one chart show several variables. Pandas plotting is a convenient route to common charts, while Matplotlib gives you more direct control.

  75. Maria

    For other data sources, SQL is an important example. Pandas can read the result of a SQL query into a DataFrame, and it can also read a whole table when the appropriate SQLAlchemy setup is used. The corresponding to_sql method writes a DataFrame to a table, with options for what to do if that table already exists.

  76. Michael

    HTML tables can be read with read_html, which searches a page and returns parsed tables. This can be a quick way to obtain public tabular data, such as a table from Wikipedia, but web pages are designed for people, not necessarily for data import. Complicated headers, repeated headings, or merged cells may require extra cleaning.

  77. Maria

    Excel files can be read with read_excel, usually one sheet at a time, and you can specify which sheet to use. Pandas also provides an ExcelFile workflow for inspecting sheet names and then reading selected sheets. Writing to Excel is possible too, though the necessary supporting libraries and platform setup can vary.

  78. Michael

    The tutorial ends with a short Python refresher for learners arriving from another language. It recommends Python 3; Python 2 was deprecated in 2020. Python is described as a high-level, interpreted, general-purpose language with object-oriented, functional, and imperative features.

  79. Maria

    Python defines blocks through indentation. You use def to define a function, if, elif, and else for conditional logic, and return to provide a result. If a function has no explicit return statement, it returns None. Comments begin with the hash symbol.

  80. Michael

    Python includes integers, floating-point numbers, strings, Booleans, and None, along with other tools such as decimal arithmetic when that is needed. It is dynamically typed, so you don’t declare a variable’s type in advance, but it is also strongly typed: incompatible operations can raise errors. Functions such as int, str, and float can convert values when appropriate.

  81. Maria

    The core collections include lists, tuples, dictionaries, and sets. Lists are ordered and mutable; tuples are ordered and immutable. Dictionaries associate keys with values, while sets contain unique values and are useful for membership checks.

  82. Michael

    A for loop in Python usually iterates over a collection, rather than using the traditional counter-based form found in some languages. You can loop through a list, dictionary keys, values, or key-value pairs. While loops exist, but the tutorial advises preferring a for loop when it expresses the task clearly.

  83. Maria

    Python also comes with a broad standard library, and the wider ecosystem has libraries for tasks such as numerical computing, web development, and machine learning. You import modules to use their functionality. When something goes wrong, try and except blocks let you handle exceptions instead of letting the program stop unexpectedly.

  84. Michael

    So we’ve covered the full journey: why analysis turns data into decision-supporting information, how Python’s ecosystem helps, and how to work with data in notebooks, NumPy, pandas, and visualizations. The practical habit to keep is to inspect structure and summaries, clean with domain knowledge, ask focused questions, and communicate findings clearly.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent