3

I have a variable storing a string timestamp (in Unix time) that I'd like to append to an existing Python Pandas Data Frame as a column. That is, I'd like the column to contain 143 repeats of the single timestamp, because this is the observation count of the data frame. Thanks.

1 Answer 1

2
In [1]: import pandas as pd

In [2]: df = pd.DataFrame(np.random.rand(4,4))

In [3]: ts = np.datetime64(int('1326706251'), 's')

In [4]: df['repeating'] = ts

In [5]: print df
          0         1         2         3           repeating
0  0.007547  0.909486  0.742417  0.932215 2012-01-16 09:30:51
1  0.287323  0.748129  0.433262  0.323886 2012-01-16 09:30:51
2  0.664347  0.817915  0.933342  0.847160 2012-01-16 09:30:51
3  0.905030  0.638067  0.362654  0.273651 2012-01-16 09:30:51
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.