Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

15 Steps to Getting Started with Pandas — Complete Beginner’s Guide
Latest   Machine Learning

15 Steps to Getting Started with Pandas — Complete Beginner’s Guide

Last Updated on July 17, 2023 by Editorial Team

Author(s): Fares Sayah

Originally published on Towards AI.

Essential Pandas functions for working with data — Read, Write and Manipulate Data

Photo by Kari Shea on Unsplash

Pandas is a fast, powerful, flexible, and easy-to-use open-source data analysis and manipulation tool, built on top of the Python programming language. Mastering Pandas will take your analysis skills to the next level and knowing best practices will save you a lot of time and energy.

In this article, we will explore the Pandas library and how to use it to handle different types of data that you may face during your analysis. By the end of the tutorial, you’ll be more fluent in using Pandas functionalities.

Links to Data used in this Article:

To read the data you just need to paste the in pd.read_csv() function:

Table Of Content

1. How to read/write a tabular data file using Pandas?
2. How do I select a pandas Series from a DataFrame?
3. How do I rename columns in a pandas DataFrame?
4. How do I remove columns from Pandas DataFrames?
5. How do I sort a Pandas DataFrames or Series?
6. How do I filter rows of a Pandas DataFrames by column value?
7. How do I use string methods in pandas?
8. How do I change the data type of a pandas Series?
9. When should I use a “groupby” in pandas?
10. How do I handle missing values in pandas?
11. What do I need to know about the Pandas index?
12. How do I select multiple rows and columns from a pandas DataFrame?
13. How do I work with dates and times in pandas?
14. How to find and remove duplicate rows in pandas?
15. How do I apply a function to a pandas Series or DataFrame?

1. How to read/write a tabular data file using Pandas?

pandas.read_csv() is the best and easy way to read a csv file. It has a lot of parameters that satisfy most of the cases. To read only columns we need, pass a list of columns names that you want to usecols. We can also specify the number of rows just by passing a number to nrows.

Figure 1: Read/Write Data with Pandas

2. How do I select a Pandas Series from a DataFrame?

We can select Pandas Series by accessing directly the column, eg: df[‘City’] another way is to access the column as a property, but in this case, the name of the column must obey the conditions of variable naming(no spacing, begins with a letter, …).

City Shape Reported State
0 Ithaca TRIANGLE NY
1 Willingboro OTHER NJ
2 Holyoke OVAL CO
3 Abilene DISK KS
4 New York Worlds Fair LIGHT NY
0 Ithaca
1 Willingboro
2 Holyoke
3 Abilene
4 New York Worlds Fair
Name: City, dtype: object
Figure 2: Select a Series from DataFrame

3. How do I rename columns in a Pandas DataFrame?

One way of renaming the columns in a Pandas DataFrame is by using the rename() function. This method is quite useful when we need to rename some selected columns because we need to specify information only for the columns which are to be renamed.

Index(['City', 'Colors Reported', 'Shape Reported', 'State', 'Time',
'Location'],
dtype='object')
Index(['City', 'Colors_Reported', 'Shape_Reported', 'State', 'Time',
'Location'],
dtype='object')
Index(['city', 'colors reported', 'shape reported', 'state', 'time',
'location'],
dtype='object')
Index(['city', 'colors_reported', 'shape_reported', 'state', 'time',
'location'],
dtype='object')
Figure 3: Rename Columns with Pandas — Part 1

The columns can also be renamed by directly assigning a list containing the new names to the columns attribute of the DataFrame the object for which we want to rename the columns. The disadvantage of this method is that we need to provide new names for all the columns even if want to rename only some of the columns.

Figure 4: Rename Columns with Pandas — Part 2

4. How do I remove columns from Pandas DataFrames?

Drop one or more than one column from a DataFrame can be achieved in multiple ways. The most common one in .drop() method. Using it we can drop multiple columns or rows.

Index(['City', 'Colors Reported', 'Shape Reported', 'State', 'Time',
'Location'],
dtype='object')
Index(['City', 'Shape Reported', 'State', 'Time', 'Location'], dtype='object')Index(['Shape Reported', 'State', 'Time'], dtype='object')
Figure 5: Remove Columns from Pandas DataFrame

5. How do I sort a Pandas DataFrames or Series?

To sort a Pandas DataFrame we use .sort_values() method. It can sort values in Ascending or Descending order.

star_rating title duration
0 9.3 The Shawshank Redemption 142
1 9.2 The Godfather 175
2 9.1 The Godfather: Part II 200
3 9.0 The Dark Knight 152
4 8.9 Pulp Fiction 154
star_rating title duration
941 7.4 A Bridge Too Far 175
938 7.4 Alice in Wonderland 75
975 7.4 Back to the Future Part III 118
933 7.4 Beetlejuice 92
972 7.4 Blue Valentine 112
Figure 6: Sort a Pandas DataFrames — Part 1

We can sort by multiple criteria by passing a list of columns you want to sort by.

Figure 7: Sort a Pandas DataFrames — Part 2

6. How do I filter rows of a Pandas DataFrames by column value?

Filtering is a common operation in data analysis and Pandas provides a variety of ways to filter data points. Here we used: Logical operators and Multiple logical operators. There are a lot of other filtering techniques like: .isin(), .query()

Figure 8: Filter Rows of a Pandas DataFrames by Column Value — Part 1

To apply filtering by multiple criteria, use the ‘&’, ‘U+007C’ instead of ‘and’, ‘or’. If we have a longer condition like this one we can use ‘isin’ method.

Figure 9: Filter Rows of a Pandas DataFrames by Column Value — Part 2

7. How do I use string methods in pandas?

The string methods on Index are especially useful for cleaning up or transforming DataFrame columns.

0 CHIPS AND FRESH TOMATO SALSA
1 IZZE
2 NANTUCKET NECTAR
3 CHIPS AND TOMATILLO-GREEN CHILI SALSA
4 CHICKEN BOWL
Name: item_name, dtype: object
0 chips and fresh tomato salsa
1 izze
2 nantucket nectar
3 chips and tomatillo-green chili salsa
4 chicken bowl
Name: item_name, dtype: object
0 False
1 False
2 False
3 False
4 False
Name: item_name, dtype: bool
Figure 10: Apply String Methods to Texts in DataFrame

8. How do I change the data type of a pandas Series?

To check the types of your data, you can use .dtypes and it will return a pandas series of columns associated with there dtype. The simplest way to convert a pandas column of data to a different type is to use astype().

order_id int64
quantity int64
item_name object
choice_description object
item_price object
dtype: object
dtype('float64')
Figure 11: Change the Data Type of a Pandas Series

9. When should I use a “groupby” in pandas?

groupby()’: Group DataFrame or Series using a mapper or by a Series of columns. A groupby operation involves some combination of splitting the object, applying a function, and combining the results. This can be used to group large amounts of data and compute operations on these groups.

genre
Action 126.485294
Adventure 134.840000
Animation 96.596774
Biography 131.844156
Comedy 107.602564
Crime 122.298387
Drama 126.539568
Family 107.500000
Fantasy 112.000000
Film-Noir 97.333333
History 66.000000
Horror 102.517241
Mystery 115.625000
Sci-Fi 109.000000
Thriller 114.200000
Western 136.666667
Name: duration, dtype: float64
count mean max min
genre
Action 136 126.485294 205 80
Adventure 75 134.840000 224 89
Animation 62 96.596774 134 75
Biography 77 131.844156 202 85
Comedy 156 107.602564 187 68
Crime 124 122.298387 229 67
Drama 278 126.539568 242 64
Family 2 107.500000 115 100
Fantasy 1 112.000000 112 112
Film-Noir 3 97.333333 111 88
History 1 66.000000 66 66
Horror 29 102.517241 146 70
Mystery 16 115.625000 160 69
Sci-Fi 5 109.000000 132 91
Thriller 5 114.200000 120 107
Western 9 136.666667 175 85
Figure 12: GroupBy in Pandas — Part 1

Multiple aggregation functions can be applied simultaneously.

Figure 12: GroupBy in Pandas — Part 2

10. How do I handle missing values in pandas?

Missing Data is a very big problem in real-life scenarios. In Pandas missing data is represented by two values: NaN or None. Panas has several useful functions for detecting, removing, and replacing null values in Pandas DataFrame: .isna() used to find NaN, .dropna() used to remove NaN, and .fillna() to fill NaN with a specific value.

(18241, 6)City 25
Colors Reported 15359
Shape Reported 2644
State 0
Time 0
Location 25
dtype: int64
(2486, 6)
(2486, 6)
(18237, 6)
2644
0
VARIOUS 2977
LIGHT 2803
DISK 2122
TRIANGLE 1889
OTHER 1402
Name: Shape Reported, dtype: int64
Figure 13: Handle Missing Values with Pandas — Part 1
Figure 14: Handle Missing Values with Pandas — Part 2
Figure 15: Handle Missing Values with Pandas — Part 3

11. What do I need to know about the Pandas index?

It is common in tabular data to use an index in the range of 0 to len(data) . For specific cases (like time series data) we need to change the index to something more meaningful. To set an index, we simply pass the column to .set_index().

Int64Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8,
9,
...
18231, 18232, 18233, 18234, 18235, 18236, 18237, 18238, 18239,
18240],
dtype='int64', length=18241)
Index([ 'Ithaca , NY', 'Willingboro , NJ',
'Holyoke , CO', 'Abilene , KS',
'New York Worlds Fair , NY', 'Valley City , ND',
'Crater Lake , CA', 'Alma , MI',
'Eklutna , AK', 'Hubbard , OR',
...
'Pismo Beach , CA', 'Lodi , WI',
'Anchorage , AK', 'Capitola , CA',
'Fountain Hills , AZ', 'Grant Park , IL',
'Spirit Lake , IA', 'Eagle River , WI',
'Eagle River , WI', 'Ybor , FL'],
dtype='object', name='Location', length=18241)
Figure 16: Change DataFrame Index

12. How do I select multiple rows and columns from a pandas DataFrame?

Pandas is built on top of NumPy so it tries to pursue his conventions about slicing. while ‘iloc’ works with numerics, it's built like NumPy array. this is not the case for ‘loc’ which slices on other types.

City Holyoke
Shape Reported OVAL
State CO
Name: 2, dtype: object
City Shape Reported State
0 Ithaca TRIANGLE NY
1 Willingboro OTHER NJ
2 Holyoke OVAL CO
City State
0 Ithaca NY
1 Willingboro NJ
2 Holyoke CO
Figure 17: Select Multiple Rows and Columns

13. How do I work with dates and times in pandas?

DateTime is a collection of dates and times in the format of “yyyy-mm-dd HH:MM:SS” where yyyy-mm-dd is referred to as the date and HH:MM:SS is referred to as Time. Having our dates as datetime64 objects will allow us to access a lot of date and time information through the .dt API.

.to_datetime() will convert the string presenting our data to datetime64[ns] object.

0 1930-06-01 22:00:00
1 1930-06-30 20:00:00
2 1931-02-15 14:00:00
3 1931-06-01 13:00:00
4 1933-04-18 19:00:00
Name: Time, dtype: datetime64[ns]
0 22
1 20
2 14
3 13
4 19
Name: Time, dtype: int64
0 Sunday
1 Monday
2 Sunday
3 Monday
4 Tuesday
Name: Time, dtype: object
Figure 18: Work with DateTime Objects in Pandas

14. How to find and remove duplicate rows in pandas?

An important part of Data analysis is analyzing Duplicate Values and removing them. Pandas duplicated() method helps in analyzing duplicate values only. It returns a boolean series that is True only for Unique elements.

(943, 4)
148
7
(936, 4)
Figure 19: Handle Duplicate Rows

15. How do I apply a function to a pandas Series or DataFrame?

Pandas.apply allow the users to pass a function and apply it on every single value of the Pandas series.

age gender occupation zip_code
user_id
1 24 M technician 85711
2 53 F other 94043
3 23 M writer 32067
4 24 M technician 43537
5 33 F other 15213
user_id
1 1
2 0
3 1
4 1
5 0
Name: gender, dtype: int64
Man 889
Child 54
Name: age, dtype: int64
Figure 20: Apply a Function to a Pandas Series

Conclusion

Mastering Pandas will take your analysis skills to the next level and knowing best practices will save you a lot of time and energy. In this article we covered:

  • 15 hands-on recipes to quickly start using Pandas. All of them are useful and come in handy for particular cases.
  • Pandas is a powerful library for both data analysis and manipulation. It provides numerous functions and methods to handle data in tabular form. As with any other tool, the best way to learn Pandas is through practicing.

Thank you for reading. Please let me know if you have any feedback or suggestions.

References

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓

Sign Up for the Course
`; } else { console.error('Element with id="subscribe" not found within the page with class "home".'); } } }); // Remove duplicate text from articles /* Backup: 09/11/24 function removeDuplicateText() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, strong'); // Select the desired elements const seenTexts = new Set(); // A set to keep track of seen texts const tagCounters = {}; // Object to track instances of each tag elements.forEach(el => { const tagName = el.tagName.toLowerCase(); // Get the tag name (e.g., 'h1', 'h2', etc.) // Initialize a counter for each tag if not already done if (!tagCounters[tagName]) { tagCounters[tagName] = 0; } // Only process the first 10 elements of each tag type if (tagCounters[tagName] >= 2) { return; // Skip if the number of elements exceeds 10 } const text = el.textContent.trim(); // Get the text content const words = text.split(/\s+/); // Split the text into words if (words.length >= 4) { // Ensure at least 4 words const significantPart = words.slice(0, 5).join(' '); // Get first 5 words for matching // Check if the text (not the tag) has been seen before if (seenTexts.has(significantPart)) { // console.log('Duplicate found, removing:', el); // Log duplicate el.remove(); // Remove duplicate element } else { seenTexts.add(significantPart); // Add the text to the set } } tagCounters[tagName]++; // Increment the counter for this tag }); } removeDuplicateText(); */ // Remove duplicate text from articles function removeDuplicateText() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, strong'); // Select the desired elements const seenTexts = new Set(); // A set to keep track of seen texts const tagCounters = {}; // Object to track instances of each tag // List of classes to be excluded const excludedClasses = ['medium-author', 'post-widget-title']; elements.forEach(el => { // Skip elements with any of the excluded classes if (excludedClasses.some(cls => el.classList.contains(cls))) { return; // Skip this element if it has any of the excluded classes } const tagName = el.tagName.toLowerCase(); // Get the tag name (e.g., 'h1', 'h2', etc.) // Initialize a counter for each tag if not already done if (!tagCounters[tagName]) { tagCounters[tagName] = 0; } // Only process the first 10 elements of each tag type if (tagCounters[tagName] >= 10) { return; // Skip if the number of elements exceeds 10 } const text = el.textContent.trim(); // Get the text content const words = text.split(/\s+/); // Split the text into words if (words.length >= 4) { // Ensure at least 4 words const significantPart = words.slice(0, 5).join(' '); // Get first 5 words for matching // Check if the text (not the tag) has been seen before if (seenTexts.has(significantPart)) { // console.log('Duplicate found, removing:', el); // Log duplicate el.remove(); // Remove duplicate element } else { seenTexts.add(significantPart); // Add the text to the set } } tagCounters[tagName]++; // Increment the counter for this tag }); } removeDuplicateText(); //Remove unnecessary text in blog excerpts document.querySelectorAll('.blog p').forEach(function(paragraph) { // Replace the unwanted text pattern for each paragraph paragraph.innerHTML = paragraph.innerHTML .replace(/Author\(s\): [\w\s]+ Originally published on Towards AI\.?/g, '') // Removes 'Author(s): XYZ Originally published on Towards AI' .replace(/This member-only story is on us\. Upgrade to access all of Medium\./g, ''); // Removes 'This member-only story...' }); //Load ionic icons and cache them if ('localStorage' in window && window['localStorage'] !== null) { const cssLink = 'https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css'; const storedCss = localStorage.getItem('ionicons'); if (storedCss) { loadCSS(storedCss); } else { fetch(cssLink).then(response => response.text()).then(css => { localStorage.setItem('ionicons', css); loadCSS(css); }); } } function loadCSS(css) { const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); } //Remove elements from imported content automatically function removeStrongFromHeadings() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, h6, span'); elements.forEach(el => { const strongTags = el.querySelectorAll('strong'); strongTags.forEach(strongTag => { while (strongTag.firstChild) { strongTag.parentNode.insertBefore(strongTag.firstChild, strongTag); } strongTag.remove(); }); }); } removeStrongFromHeadings(); "use strict"; window.onload = () => { /* //This is an object for each category of subjects and in that there are kewords and link to the keywods let keywordsAndLinks = { //you can add more categories and define their keywords and add a link ds: { keywords: [ //you can add more keywords here they are detected and replaced with achor tag automatically 'data science', 'Data science', 'Data Science', 'data Science', 'DATA SCIENCE', ], //we will replace the linktext with the keyword later on in the code //you can easily change links for each category here //(include class="ml-link" and linktext) link: 'linktext', }, ml: { keywords: [ //Add more keywords 'machine learning', 'Machine learning', 'Machine Learning', 'machine Learning', 'MACHINE LEARNING', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, ai: { keywords: [ 'artificial intelligence', 'Artificial intelligence', 'Artificial Intelligence', 'artificial Intelligence', 'ARTIFICIAL INTELLIGENCE', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, nl: { keywords: [ 'NLP', 'nlp', 'natural language processing', 'Natural Language Processing', 'NATURAL LANGUAGE PROCESSING', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, des: { keywords: [ 'data engineering services', 'Data Engineering Services', 'DATA ENGINEERING SERVICES', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, td: { keywords: [ 'training data', 'Training Data', 'training Data', 'TRAINING DATA', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, ias: { keywords: [ 'image annotation services', 'Image annotation services', 'image Annotation services', 'image annotation Services', 'Image Annotation Services', 'IMAGE ANNOTATION SERVICES', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, l: { keywords: [ 'labeling', 'labelling', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, pbp: { keywords: [ 'previous blog posts', 'previous blog post', 'latest', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, mlc: { keywords: [ 'machine learning course', 'machine learning class', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, }; //Articles to skip let articleIdsToSkip = ['post-2651', 'post-3414', 'post-3540']; //keyword with its related achortag is recieved here along with article id function searchAndReplace(keyword, anchorTag, articleId) { //selects the h3 h4 and p tags that are inside of the article let content = document.querySelector(`#${articleId} .entry-content`); //replaces the "linktext" in achor tag with the keyword that will be searched and replaced let newLink = anchorTag.replace('linktext', keyword); //regular expression to search keyword var re = new RegExp('(' + keyword + ')', 'g'); //this replaces the keywords in h3 h4 and p tags content with achor tag content.innerHTML = content.innerHTML.replace(re, newLink); } function articleFilter(keyword, anchorTag) { //gets all the articles var articles = document.querySelectorAll('article'); //if its zero or less then there are no articles if (articles.length > 0) { for (let x = 0; x < articles.length; x++) { //articles to skip is an array in which there are ids of articles which should not get effected //if the current article's id is also in that array then do not call search and replace with its data if (!articleIdsToSkip.includes(articles[x].id)) { //search and replace is called on articles which should get effected searchAndReplace(keyword, anchorTag, articles[x].id, key); } else { console.log( `Cannot replace the keywords in article with id ${articles[x].id}` ); } } } else { console.log('No articles found.'); } } let key; //not part of script, added for (key in keywordsAndLinks) { //key is the object in keywords and links object i.e ds, ml, ai for (let i = 0; i < keywordsAndLinks[key].keywords.length; i++) { //keywordsAndLinks[key].keywords is the array of keywords for key (ds, ml, ai) //keywordsAndLinks[key].keywords[i] is the keyword and keywordsAndLinks[key].link is the link //keyword and link is sent to searchreplace where it is then replaced using regular expression and replace function articleFilter( keywordsAndLinks[key].keywords[i], keywordsAndLinks[key].link ); } } function cleanLinks() { // (making smal functions is for DRY) this function gets the links and only keeps the first 2 and from the rest removes the anchor tag and replaces it with its text function removeLinks(links) { if (links.length > 1) { for (let i = 2; i < links.length; i++) { links[i].outerHTML = links[i].textContent; } } } //arrays which will contain all the achor tags found with the class (ds-link, ml-link, ailink) in each article inserted using search and replace let dslinks; let mllinks; let ailinks; let nllinks; let deslinks; let tdlinks; let iaslinks; let llinks; let pbplinks; let mlclinks; const content = document.querySelectorAll('article'); //all articles content.forEach((c) => { //to skip the articles with specific ids if (!articleIdsToSkip.includes(c.id)) { //getting all the anchor tags in each article one by one dslinks = document.querySelectorAll(`#${c.id} .entry-content a.ds-link`); mllinks = document.querySelectorAll(`#${c.id} .entry-content a.ml-link`); ailinks = document.querySelectorAll(`#${c.id} .entry-content a.ai-link`); nllinks = document.querySelectorAll(`#${c.id} .entry-content a.ntrl-link`); deslinks = document.querySelectorAll(`#${c.id} .entry-content a.des-link`); tdlinks = document.querySelectorAll(`#${c.id} .entry-content a.td-link`); iaslinks = document.querySelectorAll(`#${c.id} .entry-content a.ias-link`); mlclinks = document.querySelectorAll(`#${c.id} .entry-content a.mlc-link`); llinks = document.querySelectorAll(`#${c.id} .entry-content a.l-link`); pbplinks = document.querySelectorAll(`#${c.id} .entry-content a.pbp-link`); //sending the anchor tags list of each article one by one to remove extra anchor tags removeLinks(dslinks); removeLinks(mllinks); removeLinks(ailinks); removeLinks(nllinks); removeLinks(deslinks); removeLinks(tdlinks); removeLinks(iaslinks); removeLinks(mlclinks); removeLinks(llinks); removeLinks(pbplinks); } }); } //To remove extra achor tags of each category (ds, ml, ai) and only have 2 of each category per article cleanLinks(); */ //Recommended Articles var ctaLinks = [ /* ' ' + '

Subscribe to our AI newsletter!

' + */ '

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

'+ '

Towards AI has published Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!

' + '
' + '' + '' + '

Note: Content contains the views of the contributing authors and not Towards AI.
Disclosure: This website may contain sponsored content and affiliate links.

' + 'Discover Your Dream AI Career at Towards AI Jobs' + '

Towards AI has built a jobs board tailored specifically to Machine Learning and Data Science Jobs and Skills. Our software searches for live AI jobs each hour, labels and categorises them and makes them easily searchable. Explore over 10,000 live jobs today with Towards AI Jobs!

' + '
' + '

🔥 Recommended Articles 🔥

' + 'Why Become an LLM Developer? Launching Towards AI’s New One-Stop Conversion Course'+ 'Testing Launchpad.sh: A Container-based GPU Cloud for Inference and Fine-tuning'+ 'The Top 13 AI-Powered CRM Platforms
' + 'Top 11 AI Call Center Software for 2024
' + 'Learn Prompting 101—Prompt Engineering Course
' + 'Explore Leading Cloud Providers for GPU-Powered LLM Training
' + 'Best AI Communities for Artificial Intelligence Enthusiasts
' + 'Best Workstations for Deep Learning
' + 'Best Laptops for Deep Learning
' + 'Best Machine Learning Books
' + 'Machine Learning Algorithms
' + 'Neural Networks Tutorial
' + 'Best Public Datasets for Machine Learning
' + 'Neural Network Types
' + 'NLP Tutorial
' + 'Best Data Science Books
' + 'Monte Carlo Simulation Tutorial
' + 'Recommender System Tutorial
' + 'Linear Algebra for Deep Learning Tutorial
' + 'Google Colab Introduction
' + 'Decision Trees in Machine Learning
' + 'Principal Component Analysis (PCA) Tutorial
' + 'Linear Regression from Zero to Hero
'+ '

', /* + '

Join thousands of data leaders on the AI newsletter. It’s free, we don’t spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

',*/ ]; var replaceText = { '': '', '': '', '
': '
' + ctaLinks + '
', }; Object.keys(replaceText).forEach((txtorig) => { //txtorig is the key in replacetext object const txtnew = replaceText[txtorig]; //txtnew is the value of the key in replacetext object let entryFooter = document.querySelector('article .entry-footer'); if (document.querySelectorAll('.single-post').length > 0) { //console.log('Article found.'); const text = entryFooter.innerHTML; entryFooter.innerHTML = text.replace(txtorig, txtnew); } else { // console.log('Article not found.'); //removing comment 09/04/24 } }); var css = document.createElement('style'); css.type = 'text/css'; css.innerHTML = '.post-tags { display:none !important } .article-cta a { font-size: 18px; }'; document.body.appendChild(css); //Extra //This function adds some accessibility needs to the site. function addAlly() { // In this function JQuery is replaced with vanilla javascript functions const imgCont = document.querySelector('.uw-imgcont'); imgCont.setAttribute('aria-label', 'AI news, latest developments'); imgCont.title = 'AI news, latest developments'; imgCont.rel = 'noopener'; document.querySelector('.page-mobile-menu-logo a').title = 'Towards AI Home'; document.querySelector('a.social-link').rel = 'noopener'; document.querySelector('a.uw-text').rel = 'noopener'; document.querySelector('a.uw-w-branding').rel = 'noopener'; document.querySelector('.blog h2.heading').innerHTML = 'Publication'; const popupSearch = document.querySelector$('a.btn-open-popup-search'); popupSearch.setAttribute('role', 'button'); popupSearch.title = 'Search'; const searchClose = document.querySelector('a.popup-search-close'); searchClose.setAttribute('role', 'button'); searchClose.title = 'Close search page'; // document // .querySelector('a.btn-open-popup-search') // .setAttribute( // 'href', // 'https://medium.com/towards-artificial-intelligence/search' // ); } // Add external attributes to 302 sticky and editorial links function extLink() { // Sticky 302 links, this fuction opens the link we send to Medium on a new tab and adds a "noopener" rel to them var stickyLinks = document.querySelectorAll('.grid-item.sticky a'); for (var i = 0; i < stickyLinks.length; i++) { /* stickyLinks[i].setAttribute('target', '_blank'); stickyLinks[i].setAttribute('rel', 'noopener'); */ } // Editorial 302 links, same here var editLinks = document.querySelectorAll( '.grid-item.category-editorial a' ); for (var i = 0; i < editLinks.length; i++) { editLinks[i].setAttribute('target', '_blank'); editLinks[i].setAttribute('rel', 'noopener'); } } // Add current year to copyright notices document.getElementById( 'js-current-year' ).textContent = new Date().getFullYear(); // Call functions after page load extLink(); //addAlly(); setTimeout(function() { //addAlly(); //ideally we should only need to run it once ↑ }, 5000); }; function closeCookieDialog (){ document.getElementById("cookie-consent").style.display = "none"; return false; } setTimeout ( function () { closeCookieDialog(); }, 15000); console.log(`%c 🚀🚀🚀 ███ █████ ███████ █████████ ███████████ █████████████ ███████████████ ███████ ███████ ███████ ┌───────────────────────────────────────────────────────────────────┐ │ │ │ Towards AI is looking for contributors! │ │ Join us in creating awesome AI content. │ │ Let's build the future of AI together → │ │ https://towardsai.net/contribute │ │ │ └───────────────────────────────────────────────────────────────────┘ `, `background: ; color: #00adff; font-size: large`); //Remove latest category across site document.querySelectorAll('a[rel="category tag"]').forEach(function(el) { if (el.textContent.trim() === 'Latest') { // Remove the two consecutive spaces (  ) if (el.nextSibling && el.nextSibling.nodeValue.includes('\u00A0\u00A0')) { el.nextSibling.nodeValue = ''; // Remove the spaces } el.style.display = 'none'; // Hide the element } }); // Add cross-domain measurement, anonymize IPs 'use strict'; //var ga = gtag; ga('config', 'G-9D3HKKFV1Q', 'auto', { /*'allowLinker': true,*/ 'anonymize_ip': true/*, 'linker': { 'domains': [ 'medium.com/towards-artificial-intelligence', 'datasets.towardsai.net', 'rss.towardsai.net', 'feed.towardsai.net', 'contribute.towardsai.net', 'members.towardsai.net', 'pub.towardsai.net', 'news.towardsai.net' ] } */ }); ga('send', 'pageview'); -->