Created
May 23, 2019 10:18
-
-
Save Arqam123/92bb228844f25b05094b322234b2be7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import re | |
data = pd.read_csv("C:\\Users\\muhammad.arqam\\Downloads\\traffic_4_dataset.csv") | |
def d(x): | |
CARRIS_REGEX=r'([\-\+]?[0-9]*(\.[0-9]+)?,[\-\+]?[0-9]{2}(\.[0-9]+)?)' | |
pattern = re.compile(CARRIS_REGEX, re.UNICODE) | |
list = [] | |
for match in pattern.finditer(x): | |
list.append(match.groups()[0]) | |
return " ".join(list) | |
data2 = data['Steps'].apply(d) | |
data['Steps'] = data2 | |
#data.to_csv("C:\\Users\\muhammad.arqam\\Pictures\\Camera Roll\clean_traffic_4_dataset.csv", index=False) | |
df = pd.DataFrame(data2.str.split(' ',-1).tolist()).apply(pd.Series).unstack().reset_index(drop=True).dropna() | |
df2 = pd.DataFrame(df.str.split(',',-1).tolist()) | |
df2.to_csv("C:\\Users\\muhammad.arqam\\Pictures\\Camera Roll\old_points.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment