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
3
votes
1 answer

Python Pandas - Creating a timeseries from a csv file

I would like to create a timeseries 'aapl' by reading a csv file and set the first column as DatetimeIndex. Here some lines from the csv file: 2000-01-03, 111.937502 2000-01-04, 102.500003 2000-01-05, 103.999997 2000-01-06, 94.999998 2000-01-07, …
René
  • 4,594
  • 5
  • 23
  • 52
3
votes
1 answer

Iterating Through Timeseries One Day at a Time

Massive edit: Ok, so I have a timeseries dataframe at the minute level. For sake of example, this dataframe is one year's worth of data. I am attempting to create an analytical model that will iterate through this data day-to-day. The function…
supernoob
  • 55
  • 1
  • 7
3
votes
1 answer

How to align indexes of many dataframes and fill in respective missing values in Pandas?

I have 4 dataframes with data of similar datetime indexes, however in each of them there are few missing lines and I know that the gaps can be filled using previous known data. I would like to 'align' these dataframes so that they have union of…
danilam
  • 75
  • 2
  • 5
3
votes
1 answer

When I try to drop a single row in a pandas dataframe with datetimeindex, it shifts the index

I have a dataframe with a datetimeindex index. When i try and drop a single row by its index value, the number of rows become N-1 correctly, but the times in the index shift. In fact, a large chunk of rows is chopped from the start, and then a…
cperlmutter
  • 308
  • 3
  • 9
3
votes
2 answers

How to speed up DatetimeIndex processing?

I have a large pandas DataFrame (around 1050000 entries). One of the columns is of type datetime. I want to extract year, month and weekday. The problem is that the code shown below is extremely slow: df['Year'] =…
Klausos Klausos
  • 15,308
  • 51
  • 135
  • 217
3
votes
1 answer

Getting a time index in python for pandas dataframe

I'm having a bit of trouble getting the right time index for my pandas dataframe. import pandas as pd from datetime import strptime import numpy as np stockdata = pd.read_csv("/home/stff/symbol_2012-02.csv", parse_dates…
Taylor
  • 1,797
  • 4
  • 26
  • 51
2
votes
3 answers

select all the values between two days independently from the year in pandas

Let's say that I have the following…
diedro
  • 511
  • 1
  • 3
  • 15
2
votes
1 answer

How to convert a pandas DatetimeIndex to Array of Timestamps?

I've been digging at this, but think I've confused myself on the various ways pandas can represent dates and times. I've imported a csv of data which includes columnds for year, month, day, etc, and then converted that to a datetime column and then…
Benjamin Brannon
  • 295
  • 1
  • 3
  • 13
2
votes
2 answers

Datetime rolling count per category in Pandas

Starting from a DataFrame with a date and user column, I'd like to add a third count_past_5_days column to indicate the rolling count of occurrences of each row's user during the past 5…
Jivan
  • 21,522
  • 15
  • 80
  • 131
2
votes
1 answer

create a "Business Hour" column to indicate whether a particular timestamp was within business hours in pandas

I'm trying to add a "Buiness_hour" to the dataframe base on value of the datetime index. Say if an entry is fall between 0800 to 1800, the entry under the "Business_hour" would return "Yes" else "No". The existing df is…
1cjtc jj
  • 77
  • 4
2
votes
2 answers

How to select only the last n days every month in the given pd.DatetimeIndex

For example, datetimeidx = pd.DatetimeIndex( ['1999-03-01', '1999-03-02', '1999-03-03', '1999-03-04', '1999-03-05', '1999-03-08', '1999-03-09', '1999-03-10', '1999-03-11', '1999-03-12', '2021-11-16', '2021-11-17', …
Yanghoon
  • 572
  • 5
  • 18
2
votes
3 answers

Split date index to yearly index and monthly columns

I have a DataFrame like this: data_date value 2016-01-01 1 2016-01-02 2 2017-02-05 3 2017-02-07 4 2017-03-09 5 I need to convert it to a table with years as the index and months as the columns. (aggregate using sum) The final output should…
Shubham Periwal
  • 2,198
  • 2
  • 8
  • 26
2
votes
2 answers

Pandas shift datetimeindex takes too long time running

I have a running time issue with shifting a large dataframe with datetime index. Example using created dummy data: df =…
zonna
  • 46
  • 1
  • 9
2
votes
1 answer

loop through multiple dataframes and create datetime index then join dataframes

I have 9 dataframes of different lengths but similar formats. Each dataframe has a year, month, and day column with dates that span from 1/1/2009-12/31/2019, but some dataframes are missing data for some days. I would like to build one large…
obscuredbyclouds
  • 189
  • 1
  • 1
  • 15
2
votes
1 answer

change specific date in a datetimeindex

I have a simple dataframe containing a datetimeindex and a column for holiday names. It is structured as follows: index = ['2016-12-25','2017-04-07','2017-12-26','2018-04-07'] data = {'holiday_name': ['xmas','independence','xmas','independence']} df…
jcf
  • 180
  • 9