How to deal with an Item in a List in Python?
DATA MUNGING DATA CLEANING PYTHON MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

How to deal with an Item in a List in Python?

How to deal with an Item in a List in Python?

This recipe helps you deal with an Item in a List in Python

Recipe Objective

Have you tried to change any item in a array or tired to manupulate it?

So this is the recipe on how we can deal with an Item in a List in Python.

Step 1 - Creating List

We have created a list named sales with different values Sales = [482, 93, 392, 920, 813, 199, 374, 237, 244]

Step 2 - Changing Values

Here we have defined a function to return the values after adding 100 to the previous value. After that we have mapped this updated feature and sales. def updated(x): return x + 100 print(list(map(updated, Sales))) Now we have defined a loop in which we will add 10 to each value of previous feature i.e updated. salesUpdated = [] for x in Sales: salesUpdated.append(x + 10) print(salesUpdated) Now we have defined a mapping function to add 100 in each value of items in sales and we are using lambda function for this. print(list(map((lambda x: x + 100), Sales))) So the output comes as

[582, 193, 492, 1020, 913, 299, 474, 337, 344]

[492, 103, 402, 930, 823, 209, 384, 247, 254]

[582, 193, 492, 1020, 913, 299, 474, 337, 344]

Download Materials

Relevant Projects

Build a Face Recognition System in Python using FaceNet
In this deep learning project, you will build your own face recognition system in Python using OpenCV and FaceNet by extracting features from an image of a person's face.

Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Census Income Data Set Project - Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based on census data.

Churn Prediction in Telecom using Machine Learning in R
Estimating churners before they discontinue using a product or service is extremely important. In this ML project, you will develop a churn prediction model in telecom to predict customers who are most likely subject to churn.

Abstractive Text Summarization using Transformers-BART Model
Deep Learning Project to implement an Abstractive Text Summarizer using Google's Transformers-BART Model to generate news article headlines.

Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.