Tuesday, February 14, 2023

Control char

 import pandas as pd

import re


# create a sample dataframe

df = pd.DataFrame({'text': ['hello\tworld', 'hi\nthere', 'how\rare you?']})


# define a function to search for control characters and get their position

def find_control_char(string):

    # search for control characters using regular expression

    pattern = re.compile(r'[\x00-\x1F\x7F]')

    match = pattern.search(string)

    if match:

        return match.start()

    else:

        return None


# apply the function to the dataframe

df['control_char_pos'] = df['text'].apply(find_control_char)


print(df)


Tuesday, October 25, 2011

Introduction

This is blog is all about how you can excel your skill in SAS.Please post your questions or errors .I will try to get back with solutions as soon as possible.