Primary competition visual

RMB Monthly Mini Challenge #1: Nowcast April

Helping South Africa
$600 USD
Completed (over 3 years ago)
Forecast
600 joined
131 active
Starti
21 Mar 23
Closei
01 May 23
Reveali
24 May 23
User avatar
ihar
Adolf Würth GmbH & Co. KG
Month in "Naamsa_Vehicle_Sales.csv" and "PayProp_Rental_Index.csv"
Data Ā· 22 Mar 2023, 14:30 Ā· 8

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...

Discussion 8 answers
User avatar
zreal135Ambassador
Zindi Ambassador

What programming language are you using? R or Python?

Upvotes 0
User avatar
ihar

Python

Upvotes 0
User avatar

check converting timestamp into dates

Upvotes 0
User avatar
Jaw22

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...

Upvotes 0
User avatar
ihar

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

Upvotes 0
User avatar
ihar

It looks like a number of days after some defined date.

Upvotes 0
User avatar

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.

Upvotes 1
User avatar
zreal135Ambassador
Zindi Ambassador

I will check it out and get back to you. But if you have done it let me know

Upvotes 0