Questions tagged [datetimeindex]

Immutable ndarray of datetime64 data, represented internally as int64

Immutable ndarray of datetime64 data, represented internally as int64, and which can be boxed to Timestamp objects that are subclasses of datetime and carry metadata such as frequency information.

325 questions
2
votes
3 answers

How do I remove the year and month from a DatetimeIndex in pandas?

I have a pandas dataframe: import numpy as np import pandas as pd idx = pd.DataFrame(["2017-01-01 00:00:41","2017-01-01 00:06:53",\ "2017-01-01 00:07:10"],columns=["DateTime"]) df =…
Stromael
  • 168
  • 1
  • 9
2
votes
2 answers

pandas - Pythonic way to slicing DataFrame with DateTimeIndex

This question uses Python-3.7 and pandas-0.23.4. I'm currently dealing with financial datasets that I need to only retrieve the data of each trading day between 08:15 to 13:45 Variable Setup To illustrate this, I have a DataFrame variable with…
Toto Lele
  • 394
  • 2
  • 13
2
votes
3 answers

Length of a datetimeindex in python

I just cant find the answer and I know pandas eats problems like this for desert. I have a datetime index and want to know its length, in years: idx=pd.date_range('2011-07-03', '2015-07-10') expected output: 4.0191 years (4 years and 7 days) If…
Junaid Mohammad
  • 457
  • 1
  • 6
  • 18
2
votes
2 answers

Count occurrences of a string in a Dataframe with a DateTimeIndex

I have a DataFrame with a time series like so: timestamp v IceCreamOrder Location 2018-01-03 02:21:16 Chocolate South 2018-01-03 12:41:12 Vanilla North 2018-01-03 14:32:15 Strawberry North 2018-01-03 …
lespaul
  • 477
  • 2
  • 8
  • 21
2
votes
2 answers

How to seperate date, month and year from the following data frame.its a data of 8.4 Million users

I have tried using DatetimeIndex method. The column with values is as follows reg_date …
Abhishek Pal
  • 51
  • 1
  • 9
2
votes
1 answer

Normalize the frequency and extend multiple TimeSeries in a Dataframe to a given date

I have multiple monthly timeseries in a Dataframe. In order to make a dynamic vizualisation, I need to resample them monthly with the same end date for all of them. import pandas as pd evolution = [{'date': '2017-09-01', 'Name': 'A', 'Value':…
mxdbld
  • 16,747
  • 5
  • 34
  • 37
2
votes
1 answer

How do I create a rolling monthly datetime index for pandas?

I have a DatetimeIndex in pandas and I want to convert it to a rolling DatetimeIndex using the last date in the series. So if I create a sample datetime index: dates=pd.DatetimeIndex(pd.date_range(dt(2017,10,1),dt(2018,02,02))) An example Input:…
user2997582
  • 67
  • 1
  • 9
2
votes
2 answers

half yearly colorbar in matplotlib and pandas

I have a panda dataframe. I am making scatter plot and tried to categorize the data based on colorbar. I did it for monthly classification and quality classification as shown in the example code below. a = np.random.rand(366) b =…
bikuser
  • 2,013
  • 4
  • 33
  • 57
2
votes
3 answers

First value of each week in pd.Series/DataFrame

Say I have a pd.Series of daily S&P 500 values, and I would like to filter this series to get the first business day and the associated value of each week. So, for instance, my filtered series would contain the 5 September 2017 (Tuesday - no value…
2
votes
1 answer

pandas DataFrame DatetimeIndex slice error

I am very curious why I can assign value to a slice, but cannot print it out directly. Following codes shows details: import pandas as pd import numpy as np from datetime import datetime dt_start = datetime.strptime("20171010", "%Y%m%d") dt_end =…
Dracrays
  • 147
  • 11
2
votes
1 answer

How can DataFrames be merged such that the values of one that correspond to *dates* get applied to all *times* of all dates of the other?

I've got two DataFrames. One has a set of values corresponding to certain times and dates (df_1). The other has a set of values corresponding to certain dates (df_2). I want to merge these DataFrames such that the values of df_2 for dates get…
BlandCorporation
  • 1,324
  • 1
  • 15
  • 33
2
votes
2 answers

pandas DataFrame get 1st day per year from MultiIndex DateIndex

I have this DataFrame: dft2 = pd.DataFrame(np.random.randn(20, 1), columns=['A'], index=pd.MultiIndex.from_product([pd.date_range('20130101', …
Josh D
  • 794
  • 4
  • 14
  • 31
2
votes
2 answers

Extending Timeindex by adding new values in another column in Pandas.

Assume that I have the following dataframe in Pandas: index = pd.date_range(start=pd.Timestamp('2017-07-01'), end=pd.Timestamp('2017-07-01') + pd.Timedelta('10D')) df = pd.DataFrame(data=np.random.rand(11), index=index ,…
mk_sch
  • 1,060
  • 4
  • 16
  • 31
2
votes
1 answer

Pandas dataframe dates off by one day

I noticed that if I have pandas datetime index inside a pandas dataframe, the value of the dates changes when I call them by using .value Example. import pandas as…
2
votes
0 answers

Python DatetimeIndex: How to round time to centiseconds?

I have a DatetimeIndex dataframe and I am trying to round the microseconds to centiseconds. For instance, I have the following dataframe: In [71]:df= pd.date_range('2017-7-7 02:03:04.000',periods=5,freq='50ms') In [72]:df Out[72]:…
Konkos
  • 21
  • 1