fix datetime issue (#29)
Browse files- fix datetime issue (2afaf208adf592b8c13523bb479d138b40e93637)
data_sources/upload_file.py
CHANGED
@@ -65,12 +65,16 @@ def process_data_upload(data_file, session_hash):
|
|
65 |
|
66 |
for column in df.columns:
|
67 |
if type(column) is str:
|
68 |
-
|
69 |
-
if re.search(pattern, column.lower()):
|
70 |
try:
|
71 |
df[column] = pd.to_datetime(df[column])
|
72 |
except:
|
73 |
pass
|
|
|
|
|
|
|
|
|
|
|
74 |
if df[column].dtype == 'object' and isinstance(df[column].iloc[0], list):
|
75 |
df[column] = df[column].explode()
|
76 |
|
|
|
65 |
|
66 |
for column in df.columns:
|
67 |
if type(column) is str:
|
68 |
+
if "date" in column.lower() or "time" in column.lower():
|
|
|
69 |
try:
|
70 |
df[column] = pd.to_datetime(df[column])
|
71 |
except:
|
72 |
pass
|
73 |
+
if 'year' in column.lower():
|
74 |
+
try:
|
75 |
+
df[column] = pd.to_datetime(df[column], format='%Y')
|
76 |
+
except:
|
77 |
+
pass
|
78 |
if df[column].dtype == 'object' and isinstance(df[column].iloc[0], list):
|
79 |
df[column] = df[column].explode()
|
80 |
|