0

In the image I have a dataframe.In that I have a column called timestamp ,from that I want to seperate month and have to make it as a new column.How to do that?

1
  • Please include your example DF in a code block - not as an image... Also... what type is timestamp - is it a string or is it already a datetime-like obj? Commented Aug 19, 2018 at 8:46

1 Answer 1

1

If your Timestamp is not already datetime than convert like so:

df["Timestamp_converted"] = pd.to_datetime(df["Timestamp"], format="%Y-%m-%d %H:%M:%S")

You get the month as a separate column with this:

df["month"] = df.Timestamp_converted.dt.month
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.