Create tmp.py
Browse files
tmp.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
# Sample DataFrame
|
| 4 |
+
data = {'Date': [202205270000.0, '', 202206010000.0]}
|
| 5 |
+
|
| 6 |
+
df = pd.DataFrame(data)
|
| 7 |
+
|
| 8 |
+
# Define a lambda function to convert numeric date to string date
|
| 9 |
+
convert_to_date = lambda x: pd.to_datetime(str(int(x)), format='%Y%m%d', errors='coerce').strftime('%Y-%m-%d') if x != '' else ''
|
| 10 |
+
|
| 11 |
+
# Apply the lambda function to the DataFrame column
|
| 12 |
+
df['Date'] = df['Date'].apply(convert_to_date)
|
| 13 |
+
|
| 14 |
+
print(df)
|