Featured Post

PowerCurve for Beginners: A Comprehensive Guide

Image
PowerCurve is a complete suite of decision-making solutions that help businesses make efficient, data-driven decisions. Whether you're new to PowerCurve or want to understand its core concepts, this guide will introduce you to chief features, applications, and benefits. What is PowerCurve? PowerCurve is a decision management software developed by Experian that allows organizations to automate and optimize decision-making processes. It leverages data analytics, machine learning, and business rules to provide actionable insights for risk assessment, customer management, fraud detection, and more. Key Features of PowerCurve Data Integration – PowerCurve integrates with multiple data sources, including internal databases, third-party data providers, and cloud-based platforms. Automated Decisioning – The platform automates decision-making processes based on predefined rules and predictive models. Machine Learning & AI – PowerCurve utilizes advanced analytics and AI-driven models ...

The Easy Way to Split String Python Partition Method

Here's a way without the Split function you can split (or extract) a substring. In Python the method is Partition. You'll find here how to use this method with an example. 


Split string using the Partition

How to Split the string using Partition method

 

Returns Left side part

Example-1

my_string='ABCDEFGH||10||123456.25|'

my_partition=my_string.partition('|')[0]

print(my_partition)


Output

|10||123456.25|


** Process exited - Return Code: 0 **
Press Enter to exit terminal

Example-2

Returns from the separator to last of the string.

my_string='ABCDEFGH||10||123456.25|'
my_partition=my_string.partition('|')[-1]
print(my_partition)

Output

|10||123456.25|


** Process exited - Return Code: 0 **
Press Enter to exit terminal


The use of Rpartition to split a string in Python


Example-1

Returns except right side last separator.

my_string='ABCDEFGH||10||123456.25|'
my_partition=my_string.rpartition('|')[0]
print(my_partition)

Output

ABCDEFGH||10||123456.25


** Process exited - Return Code: 0 **
Press Enter to exit terminal

Example-2

Returns no string

my_string='ABCDEFGH||10||123456.25|'
my_partition=my_string.rpartition('|')[-1]
print(my_partition)


Output




** Process exited - Return Code: 0 **
Press Enter to exit terminal


Top Udemy courses

Comments

Popular posts from this blog

SQL Query: 3 Methods for Calculating Cumulative SUM

5 SQL Queries That Popularly Used in Data Analysis

Big Data: Top Cloud Computing Interview Questions (1 of 4)