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

0

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]

Relevant Projects

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

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.