Does anybody know how to convert "Month" column in "Naamsa_Vehicle_Sales.csv" and "PayProp_Rental_Index.csv" to normal representation?
This column has values like this: 45282, 45252, 45221...
What programming language are you using? R or Python?
Python
check converting timestamp into dates
Try using this code:
import pandas as pd
# Load the CSV file
df = pd.read_csv("Naamsa_Vehicle_Sales.csv")
# Convert the "Month" column to a date format
df["Month"] = pd.to_datetime(df["Month"])
# Extract the year and month information and create new columns
df["Year"] = df["Month"].dt.year
df["Month_Number"] = df["Month"].dt.month
# Optionally, drop the original "Month" column
df = df.drop("Month", axis=1)
# Display the resulting dataframe
print(df.head())
Hope it helps...
It's not a timestamp. It's too short. For example, the conversion of the value 45282 with `pd.to_datetime` gives 1970-01-01 00:00:00.000045282
It looks like a number of days after some defined date.
Hello, there should be a new notebook uploaded today to fix this issue of the naamsa data. You can use the same logic for the latter.
I will check it out and get back to you. But if you have done it let me know
What programming language are you using? R or Python?
Python
check converting timestamp into dates
Try using this code:
import pandas as pd
# Load the CSV file
df = pd.read_csv("Naamsa_Vehicle_Sales.csv")
# Convert the "Month" column to a date format
df["Month"] = pd.to_datetime(df["Month"])
# Extract the year and month information and create new columns
df["Year"] = df["Month"].dt.year
df["Month_Number"] = df["Month"].dt.month
# Optionally, drop the original "Month" column
df = df.drop("Month", axis=1)
# Display the resulting dataframe
print(df.head())
Hope it helps...
It's not a timestamp. It's too short. For example, the conversion of the value 45282 with `pd.to_datetime` gives 1970-01-01 00:00:00.000045282
It looks like a number of days after some defined date.
Hello, there should be a new notebook uploaded today to fix this issue of the naamsa data. You can use the same logic for the latter.
I will check it out and get back to you. But if you have done it let me know