The string is as below,
LOCATION AQI CATEGORY RANGE Dhaka a 251 VERY UNHEALTHY 195-306 Chittagong b 122 CAUTION 82-162 Gazipur c 237 VERY UNHEALTHY - Narayanganj c 335 EXTREMELY UNHEALTHY - Sylhetc c 159 UNHEALTHY - Khulna c DNA DNA - Rajshahi c 156 UNHEALTHY - Barisal c 192 UNHEALTHY - Savar DNA DNA Muradpur 126 CAUTION Cumilla 157 DNA Sandip DNA WARNING
Here, after every mixedCased words, the NULL/None values are represented as DNA for both the AQI values and climate condition. My goal is to create a dataframe as below,
| LOCATION | AQI |
|---|---|
| Dhaka | 172 |
| Chittagong | 125 |
| Gazipur | 178 |
| ... | ... |
| Khulna | 0 |
| ... | ... |
I only need the specific things as seen in the table above. Also, notice that only the AQI's DNA is to substituted to a numerical value for example 0 for my model.
My approach combined with user Corralien's one
re.sub("(\b[A-Z]+\b)|(\d+-\d+)|(\s\w\s)|(-)",' ')