Setup
>>> data = [['#fill in here', 'fill in here'], ['tom', 'jones']]
>>> df = pd.DataFrame(data, columns=['first_name', 'last_name'])
>>> df
first_name last_name
0 #fill in here fill in here
1 tom jones
Solution assuming only the strings in the first_name column matter:
>>> commented = df['first_name'].str.startswith('#')
>>> df[~commented].reset_index(drop=True)
first_name last_name
0 tom jones
Solution assuming you want to drop rows where the string in the first_name OR last_name column starts with '#'
:
>>> commented = df.apply(lambda col: col.str.startswith('#')).any(axis=1)
>>> df[~commented].reset_index(drop=True)
first_name last_name
0 tom jones
The purpose of reset_index
is to re-label the rows starting from zero.
>>> df[~commented]
first_name last_name
1 tom jones
>>>
>>> df[~commented].reset_index()
index first_name last_name
0 1 tom jones
>>>
>>> df[~commented].reset_index(drop=True)
first_name last_name
0 tom jones