I have a DataFrame like this
example = {'x': [121,'201-208-209','300A',320,'100A'], 'y': ['a','b','c','d','e']}
df = pd.DataFrame(example)
I want to know wich values are starting with a specific number. I want to know this because this way I can better categorize my database. For example, if i know that there is a row that the value of the columns "x" start with 1 I will agregate a column with "Floor 1" in the same row, but if this value start with 2 it will be "Floor 2" and so on.
CodePudding user response:
Would 'startswith' work ?
df['x'].str.startswith('1')