Contents:

Course with employment: “Profession Data Analyst”
Learn MorePython is a powerful tool for data analysis and machine learning thanks to its ability to integrate various libraries, such as Pandas, Matplotlib, NumPy, and TensorFlow. Each of these libraries is designed to perform specific tasks, making Python a versatile solution for working with data. Pandas allows for convenient data processing and analysis, Matplotlib is used for visualization, NumPy provides capabilities for numerical calculations, and TensorFlow is for creating and training neural networks. Using these libraries in combination opens up wide horizons for data analysis and machine learning specialists.
Today, we will discuss the Pandas library, its purpose, and how to import it into Python. We will also analyze the first dataset dedicated to internet speed in various countries to determine which countries have the fastest internet and which ones are slower. Pandas is a powerful data science tool, making it ideal for working with large amounts of data.
What is Pandas in Python?
Pandas is the primary data science library in Python. It is widely used by analysts and data scientists for its powerful data science tools. Created in 2008 by AQR Capital, Pandas was made open source in 2009, leading to its active development and support. The library offers convenient data structures, such as DataFrame and Series, that simplify data manipulation and analysis. Pandas continues to be an essential tool for data scientists, providing efficient solutions for processing large amounts of information.
The library is used to solve a variety of problems, including data processing, user interface creation, game development, and process automation. It provides developers with powerful tools and features that simplify software development and increase its efficiency. Using the library also promotes code sharing and collaboration between developers, making it easy to integrate ready-made solutions into their projects.
Data analytics encompasses product, marketing, and other areas. Effective work with data requires careful analysis and preparation. It is important to eliminate or fill gaps, filter, sort, and modify data as needed. The Pandas library in Python provides powerful tools for performing these tasks quickly and efficiently. It allows not only to perform necessary data manipulations but also to automate many processes, significantly simplifying the work of analysts. Using Pandas in data analytics improves the quality of analysis and accelerates the acquisition of valuable insights.
Data science and working with big data play a key role in the modern world. The Pandas library is a powerful tool for data preparation and initial analysis. It allows for the efficient processing, cleaning, and analysis of data, which is an essential step before applying machine learning or deep learning methods. Using Pandas helps you extract valuable insights from large volumes of data, significantly improving the effectiveness of analysis and prediction.
Statistics is an important aspect of data analysis, and the library provides key statistical methods necessary for working effectively with information. It includes calculating means, analyzing the distribution of data by quantiles, and many other statistical tools. These features allow users to gain a deeper understanding of the data and draw informed conclusions. Using these statistical methods contributes to a more accurate interpretation of results and improves the quality of analysis.
Working with Pandas
Specialized tools such as Google Colab and Jupyter Notebook are often used for data analysis and machine learning. These integrated development environments (IDEs) allow step-by-step and iterative interaction with data, simplifying the process of analysis and modeling. Using such platforms allows researchers and developers to effectively test algorithms and visualize results without the time-consuming task of creating a full-fledged application.
In this article, we'll look at Google Colab, a cloud-based solution for data analysis and processing. It's a convenient tool that can be run in a browser on any device, including desktops, laptops, tablets, and smartphones. Google Colab allows users to work with Python, perform calculations, and visualize data without the need to install additional software. With Google Drive integration, users can easily save and share their projects, making Google Colab an ideal choice for researchers, students, and data scientists.

Each The line of code in the screenshot represents a single action, the results of which are immediately reflected in Google Colab and Jupyter Notebook. This is especially convenient for tasks related to analytics and data science, allowing the user to quickly see the results of their actions and make decisions based on the obtained data. Pandas does not require installation when using Jupyter Notebook or Google Colab, as it is a standard library available immediately after launching the platform. You only need to import it into your code to start working with data. pd is a common shorthand for the Pandas library in Python programming. This abbreviation is widely used in educational materials, articles, and books on data analysis and information processing. We recommend using it in your projects to simplify the code and avoid unnecessary length associated with repeating the full library name. Using the pd abbreviation makes code more readable and understandable for other developers.
Series and DataFrame
In Pandas, data is represented in two main formats: Series and DataFrame. Let's consider each of these structures in more detail. A Series is a one-dimensional array that can contain data of various types and has an index for convenient access to elements. A DataFrame, in turn, is a two-dimensional table where data is organized into rows and columns, which allows you to efficiently work with tabular data. Both formats are the main tools for data analysis in Pandas and provide powerful capabilities for processing and manipulating information.
A Series is an object resembling a one-dimensional array that can contain various data types. It can easily be thought of as a table column with a sequence of values, each of which has a unique index indicating the row number. This convenient way to organize data allows you to work efficiently with various information structures, providing the ability to access and manipulate data using indices. Series are used in data analysis, making them an essential tool for developers and analysts. Let's create a simple Series in Python using the Pandas library. A Series is a one-dimensional array that can store data of various types, such as integers, strings, or floating-point numbers. To create a Series, you need to import the Pandas library and use the pd.Series() function. For example, we can create a Series from a list of values by passing it to a function. This allows us to effectively manage and analyze data. Series also supports indices, making element access more convenient. With its simple structure and powerful functionality, Series is a great tool for working with data in Python.
Now we'll display it on the screen.

Series is presented in a table format, with the first column containing element indices and the second column containing their values. This display method makes data easy to understand and quickly find the information you need. The Series' table format makes data analysis and processing more convenient, which is especially important for users working with large volumes of information.
A DataFrame is a key data type in the Pandas library, serving as the foundation for data analysis and processing. It can be visualized as a standard table containing an arbitrary number of rows and columns. The cells of this table can contain data of various types, including numeric, Boolean, string, and others. A DataFrame provides a convenient way to work with data, allowing for easy manipulation and analysis.
A DataFrame has both row and column indices, enabling efficient sorting and filtering of data. This allows you to quickly find the required cells and simplifies working with large volumes of information. Using indices in a DataFrame significantly improves the ease of data analysis and optimizes information processing.
Let's create a simple DataFrame using a dictionary and analyze its visual representation. A DataFrame is a data structure used in the Pandas library for working with tabular data. Let's start by defining a dictionary to hold our data, then create a DataFrame and display it for further inspection.
Let's look at the final result.

This example shows a table in which rows are indexed from 0 to 3, and columns are labeled according to their contents. This table has three Series: City, Year Founded, and Population. Both types of indexes are effectively used for data navigation and analysis, making it easy to extract the desired information and perform further operations on the data set.
Importing Data
Pandas provides many options for importing data. One of the most common methods is reading data from .csv files, which is widely used in data analysis. You can also import data from dictionaries, lists, or tuples. Pandas uses the pd.read_csv() function to work with .csv files, making it easy to load and process data for further analysis. Correct data import is a key step in working with Pandas, ensuring the effective use of the library's capabilities for data analysis and processing.
The read_csv function provides a number of parameters that allow you to effectively manage the data import process. These parameters allow you to customize aspects such as the delimiter, encoding, header processing, and skipping unnecessary rows. Effective use of these options helps avoid errors when loading data and ensures correct reading of information from CSV files. Correctly setting the import parameters will significantly simplify further data processing and analysis.
- sep allows you to explicitly specify the delimiter used in the imported file. The default value is ,, which corresponds to the data delimiter in .csv files. This parameter is useful when using non-standard delimiters in the source file, such as tabs or semicolons;
- dtype allows you to specify the data type in the columns after loading the .csv file. This is useful in cases where the data format was automatically detected incorrectly. For example, dates are often imported as string variables, although they have a separate type.
Detailed parameters for configuring CSV import can be found in the documentation. Here you can familiarize yourself with various options that will help optimize the data import process.
We will import a dataset containing information about mobile and landline internet speeds in various countries. We can download a ready-made dataset from the Kaggle platform. The file is in .csv format. Parameters for the read_csv function are not needed, since the data has already been prepared for further analysis.
Now let's analyze the created dataframe.
It is important to pay attention to key aspects that can affect the success of your project. First of all, you need to thoroughly research your target audience and determine their needs. Creating high-quality content that meets user interests is the basis for successful promotion.
SEO optimization plays a key role in attracting traffic to your website. Use keywords that match your audience's needs and integrate them naturally into the text. Don't forget about meta tags and descriptions, as they help improve search engine visibility.
It's also important to keep the information on your website current. Regularly updating content helps retain user interest and builds trust in your resource. Pay attention to page loading speed and the site's mobile responsiveness, as this also impacts user behavior and their desire to return.
Ultimately, a comprehensive approach to content creation and optimization will help you achieve high results and attract your target audience.
When using Google Colab or Jupyter Notebook, the print command is not required to display DataFrame or Series objects. The Pandas library allows you to output data without it, while maintaining the tabular format. If you use print(df), the visual presentation of the data will be disrupted. It is recommended to test both methods of data output to see the differences in display.
A table containing important data was displayed on the screen.

At the top The column headings are presented in the top part of the dataframe: country, broadband (average internet speed), and mobile (average mobile internet speed). On the left are indexes that range from 0 to 176, meaning the table contains 177 rows. This information is also displayed at the bottom of the Pandas table, allowing the user to quickly navigate the data and analyze internet speed metrics for different countries. Displaying the entire table isn't always necessary. To get an overview of the data, displaying the first or last five rows is sufficient. This can be done using the df.head() or df.tail() methods, respectively. The number of rows to display can be specified in parentheses. By default, this parameter is set to 5.

Now it has become much more convenient. We can immediately see the names of the columns and the type of data contained in each of them. Some cells display a NaN value, which we will discuss in more detail later.
Exploring and Describing the Data
Now we need to analyze the imported data. We will proceed in stages. First, we will evaluate the data structure, then check its correctness and completeness. After that, we will analyze key metrics and highlight important trends. It is important to pay attention to detail to get a complete understanding of the data and identify possible areas for improvement. This approach will ensure high-quality analysis and allow you to draw informed conclusions.
The first step is to check the data type in the table. This is necessary to understand the format in which the information in the dataset is presented and can help identify anomalies. For example, dates may be stored as strings, which complicates further analysis. Standard data analysis methods can be used to perform this check.
A table will be displayed on the screen, indicating the data types for each column of the dataframe. This will allow you to quickly identify what data is contained in each column and will simplify the process of data analysis. Understanding data types correctly is an important step when working with dataframes, as it affects the way we process and analyze information.

What we pay attention to Please note:
- The country column is an object data type. This data type is for string and mixed values;
- The broadband and mobile columns are float data type, meaning they refer to floating-point numbers.
In the second stage of data analysis, it is important to quickly evaluate the information and formulate preliminary conclusions. The Pandas library provides a convenient describe() method for this purpose. This method provides a statistical summary, including mean values, standard deviations, and maximum and minimum values of variables. In addition, it demonstrates the distribution of data by quantiles, which allows for a more complete understanding of the structure and characteristics of the dataset. Using the describe() method significantly simplifies the process of preliminary analysis and helps identify key trends in the data.
Let's consider the application of this method in practice.
Of course, I am ready to help with text revision. Please provide the source text that you want to adapt and optimize for SEO.

Let's look at each row in more detail.
- count is the number of filled rows in each column. We see that there are gaps in the column with data on mobile internet speed.
- mean is the average value of the speed of regular and mobile internet. We can already conclude that mobile internet in most countries is slower than cable internet.
- std is the standard deviation. An important statistical indicator showing the spread of values.
- min and max are the minimum and maximum values.
- 25%, 50% and 75% are internet speed values by percentile. Without going into statistics, a percentile is a number that shows the distribution of values in a sample. For example, in the sample with mobile internet, the 25th percentile shows that 25% of all internet speed values are less than 24.4.
This method is applicable exclusively to numeric data. There is no data for the column containing country names.
The conclusion is unambiguous: cable internet in most countries provides higher speeds than mobile internet. However, it's worth noting that in 75% of cases, wired internet speeds do not exceed 110 Mbps, while mobile internet speeds reach 69 Mbps. This indicates that for users who value high connection speeds, wired internet remains the preferred option.
Step 3. Sorting and filtering records. In our dataframe, the data is already sorted by descending wired internet speed. Now we can determine the country with the best mobile internet. To do this, we'll use the standard sort_values method, which takes two parameters: the value by which to sort and the sort order. Using this method, we can quickly identify the country with the highest mobile internet speed, which will help in further analysis and comparison of internet services in different countries.
- The name of the column by which to sort must be enclosed in single or double quotation marks.
- The ascending= parameter specifies the sorting type. If we want to sort the values from largest to smallest, we set the parameter to False. To sort from smallest to largest, we use True.
Of course, I'm happy to help with text editing. Please provide the text itself that needs to be reworked.

The ranking of countries by the quality of mobile Internet has changed, and now the top five looks different. Our new data analysis has found that the United Arab Emirates has the fastest mobile internet in the world.
However, it's worth noting that when returning to the original table sorted by wired internet speed, we see that the leader, Monaco, has a NaN value in the second column. This may raise questions about the accuracy of the data and its interpretation. This point is important to note, as it may affect the overall perception of the ranking and the reliability of comparing internet speeds across countries.
NaN in Python denotes missing data. This means that information about mobile internet speed in Monaco is missing from this dataset. Therefore, we cannot draw clear conclusions about the leaders in mobile communications based on the presented data.
We will filter the values in the dataframe, excluding countries with unknown mobile internet speeds. This will allow us to focus on the lowest metrics and get a clear picture. Without NaN values, it will be easier to identify countries with the slowest mobile internet and analyze their results.
The Pandas library offers several data filtering methods that can effectively remove NaN values. One of the most common is the dropna() method, which removes entire rows containing at least one missing value. It's important to note that this method excludes the entire row containing NaN values, not just individual cells with missing values in specific columns. This ensures data purity and avoids problems during further processing and analysis of information.

After removing empty data, the number of rows in the data frame was reduced to 136. If you go back By the second stage of analysis, you can see that this number matches the number of populated rows in the mobile column of the original dataframe. Thus, removing empty values allowed us to obtain accurate and relevant data for further work.
Let's create a new dataframe, which we'll call df_without_nan, in which NaN values will be absent. It is important to keep the original DataFrame unchanged, as it may be needed for further analysis or data processing.
Now let's sort the results by the mobile internet column from slowest to fastest and identify the country with the slowest mobile internet.

Afghanistan ranks last in mobile internet quality, followed by Palestine and Venezuela. These countries face significant connectivity challenges, which negatively impact access to information and services. Slow internet speeds and unstable connections limit user experiences and hinder the development of the digital economy. Improving communications infrastructure in these regions is essential for improving quality of life and economic growth.
How to Edit a DataFrame
Working with dataframes involves not only analyzing and processing existing data but also modifying it to suit specific needs. We can add new rows, delete unnecessary records, and aggregate data to obtain more informative results. These operations allow us to adapt the dataframe to various tasks and improve the quality of data analysis.
Let's restore the original appearance of our dataframe. To do this, we'll re-upload the CSV file with the dataset.
Let's consider a dataframe. This is a table that allows you to organize data in a format convenient for analysis. Dataframes are widely used in data analysis and machine learning due to their ability to structure information and make it easier to work with. We can perform various operations on DataFrames, such as filtering, aggregating, and visualizing data, making them an indispensable tool for analysts and statisticians.
Let's check that all the necessary data is present.

The list contains 177 countries, including those for which internet speed data is missing.
We'll add a new country to our dataframe. Given that the list already contains 177 countries, we'll decide to add the Galactic Republic from Star Wars. This will expand our dataset and add an interesting element for analysis.
Pandas uses the concat method to append data to a dataframe. This method allows you to combine multiple dataframes along an axis, making it useful when working with large amounts of data. Concat makes it easy and quick to add new rows or columns, providing flexibility in data management. Proper use of the concat method facilitates efficient data analysis and processing, which is a key aspect of working with pandas.
Let's break down the code line by line:
- First, we create a dictionary that will contain the country name, average internet speed, and average mobile internet speed.
- In the pd.DataFrame constructor, we convert the dictionary into a data frame.
- Using the concat method, we combine the original data frame with the new one into new_list. Don't forget to specify ignore_index=True so that the new line appears first.
Let's check the final result:

Success achieved. The Galactic Republic is now present in our table.
In Pandas, rows are removed using the drop method. Now let's use this method to remove the non-existent country we previously added to our dataframe.
The method takes two parameters.
- The index of the rows to be deleted—in our case, this is the row with index 0. To delete multiple rows, pass the indices as a list. For example, [0, 1, 2].
- inplace=True—zeros the indices so that the first row after deletion has an index of 0.
Run the code and get the dataframe output. A dataframe is a structured table in which data is organized into rows and columns. It is a convenient tool for data analysis and processing, allowing you to easily manipulate information, perform calculations, and visualize results. It is important to properly configure the code to correctly display and interpret the data in the dataframe.

The Galactic Republic has ceased to exist. The dataframe has returned to its original state.
When working with dataframes, you often need to find specific rows. There are two main methods for accomplishing this: index lookup and index lookup. Let's look at both of these methods in more detail.
Index lookup is performed based on the first column in the dataframe. In this context, index values are numbers ranging from 0 to 177. This method allows you to efficiently retrieve data corresponding to specific indexes, simplifying the analysis and processing of information in the dataframe.
Let's display the countries with index values 10 and 11. This will allow us to obtain information about the countries corresponding to the specified indexes. Indexes can be used to sort or filter data, making it easier to analyze and process information about different countries.
Let's look at the final results.

Filtering by index in a dataframe always starts at zero. To slice countries with indexes 5–8, use the iloc method. This method allows you to select rows and columns by their positions, making it convenient for working with data in pandas. This way, you can easily extract the data you need using indexes, which is especially useful when analyzing large data sets.
Analyzing the result:

A slice of the list from the 6th to the 8th element was obtained. Please note that the indexes and row values in this slice may differ.
Only those countries where the mobile Internet speed exceeds 100 Mbps will be displayed on the screen.
As a result, a table containing data on 18 countries was created.

It's important to understand that following basic principles and rules is crucial to achieving successful results. Failure to do so can lead to undesirable consequences. Therefore, it's essential to always remain attentive and follow established guidelines. This will help you avoid mistakes and improve the efficiency of your actions. Pay attention to detail and remember the importance of a systematic approach to problem solving. Remember that every step matters, and your choices affect the final result.
When using this method, the index values of the analyzed dataframe are stored. This allows you to work efficiently with data, preserving its structure and providing easy access to the necessary information. Using index values facilitates faster data processing and improves analysis performance.
Data aggregation is the process of combining multiple individual values into a single summary view. This feature allows you to efficiently process and analyze large volumes of information, providing users with the ability to obtain summarized data for further analysis and decision making. Data aggregation is widely used in various fields, including business, science, and analytics, and plays a key role in optimizing work with large data sets.
To calculate the average internet speed across all countries, we use the agg function, passing in the mean parameter. This method allows us to efficiently aggregate data and obtain generalized metrics, which is an important step in analyzing internet connections globally. Using the agg function with the mean parameter provides an accurate determination of the average internet speed, which allows you to better understand the internet infrastructure of different countries and identify trends in the development of internet technologies.

The average internet speed in different countries is 72.67 Mbps. This indicator reflects the level of internet connections around the world and may vary depending on the region and provider. High internet speed is an important factor for users, as it affects the quality of online services, streaming, and working with large amounts of data. Improvements in infrastructure and communication technologies contribute to an increase in average internet speed, which, in turn, has a positive impact on the availability and ease of use of network resources.
After editing the dataframe, you can save it in CSV format or in other available formats. Saving data in CSV allows you to easily share it and use it in various applications for analysis. The choice of format depends on your needs and preferences. CSV is a universal format supported by most spreadsheet programs and analytical tools.
The saved file will be available at the path you specified.
It is important to understand that proper formatting and text optimization for search engines play a key role in attracting an audience. Effective use of relevant keywords and phrases helps improve the visibility of your content in search engines. It's also important to structure your text so that it's easy to read and understand for users. This not only increases your chances of ranking high in search results but also helps retain readers' attention. It's also important to consider the relevance and usefulness of your information to ensure it meets the needs of your target audience. Optimizing meta tags and titles, as well as using internal and external links, will help improve your content's SEO ranking.
This method preserves the index values of the data frame being analyzed. This ensures data integrity and simplifies further analysis. Preserving index values is an important aspect of working with data frames, as they serve as the key to accessing and manipulating the data.
What's next?
Pandas in Python is a powerful library designed for data analysis and processing. In this article, we've covered the basic operations to help you get started with this library. For a deeper understanding of Pandas' capabilities, we recommend reading the official documentation. There are also many specialized books that will help deepen your knowledge and skills in working with Pandas, providing practical examples and tips for optimizing data analysis.
- "Learning Pandas" by Michael Haidt and Artem Gruzdev;
- "Thinking in Pandas: How to Use the Python Data Analysis Library the Right Way", Hannah Stepanek;
- "Hands-On Data Analysis with Pandas: Efficiently perform data collection, wrangling, analysis, and visualization using Python", Stefanie Molin.
Read more:
- Libraries in programming: what they are needed for and what types there are
- Test: guess where esoteric programming languages are and where they are not
- How to start programming in Python: an express guide

