I want to read in a Pandas dataframe from csv, where there are single whitespaces inside column names and the separators are multiple whitespaces. How can I tell Pandas to use only more than one consecutive whitespace as separator but ignore single whitespaces?
With specific regex pattern for sep=
option:
df = pd.read_csv(sep='\s{2,}')
\s{2,}
- quantifier, matches any whitespace character between 2
and unlimited times, as many times as possibleIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With