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
2 answers

PANDAS - Loop over two datetime indexes with different sizes to compare days and values

Looking for a more efficient way to loop over and compare datetimeindex values in two Series objects with different frequencies. Setup Imagine two Pandas series, each with a datetime index covering the same year span yet with different frequencies…
Adestin
  • 153
  • 3
  • 15
2
votes
1 answer

Hourly data in DataFrame with Pandas

I have a DataFrame that is based on a DateTimeIndex. I only want the hourly data and it is every 5 minutes unless there are some drop outs in the data. I think what I need to use is df.resample('1H'), but this automatically does…
fatalaccidents
  • 192
  • 1
  • 2
  • 13
2
votes
1 answer

filtering dataframes by datetimeindex- last business day of each month

I have a df with which can be represented below with a date column and 4 variable columns. Date A B C D 2015-10-31 6 7 3 7 2015-11-01 1 3 9 4 2015-11-02 4 5 8 1 2015-11-03 4 2 5 9 I am looking to filter the df on the last…
spacedinosaur10
  • 695
  • 3
  • 10
  • 24
2
votes
2 answers

Insert missing weekdays in pandas dataframe and fill them with NaN

I am trying to insert missing weekdays in a time series dataframe such has import pandas as pd from pandas.tseries.offsets import * df = pd.DataFrame([['2016-09-30', 10, 2020], ['2016-10-03', 20, 2424], ['2016-10-05', 5, 232]], columns=['date',…
Steven G
  • 16,244
  • 8
  • 53
  • 77
2
votes
1 answer

Create Datetime from year and month hidden in multi-index

I have a dataframe where year and month are hidden in the multi-index. I want to create a datetime index as additional column (or separate series with same index). price …
FooBar
  • 15,724
  • 19
  • 82
  • 171
2
votes
2 answers

Date range issue in pandas python

I tried this: pd.date_range(2000, periods = 365, freq = 'D',format = '%d-%m-%Y') why I am getting this result: DatetimeIndex(['1970-01-01 00:00:00.000002', '1970-01-02 00:00:00.000002', '1970-01-03 00:00:00.000002', '1970-01-04…
bikuser
  • 2,013
  • 4
  • 33
  • 57
2
votes
2 answers

Pandas plotting: How to format datetimeindex?

I am doing a barplot out of a dataframe with a 15min datetimeindex over a couple of years. Using this code: df_Vol.resample( 'A',how='sum' ).plot.bar( title='Sums per year', style='ggplot', alpha=0.8 ) Unfortunately the ticks on the…
Markus W
  • 1,451
  • 5
  • 19
  • 32
2
votes
1 answer

Why can't I apply pandas.DatetimeIndex to multiple columns?

I am trying to drop the time portion on several pandas columns using the following code: group_df['submitted_on'] = pd.DatetimeIndex(group_df['submitted_on']).to_period('d') group_df['resolved_on'] =…
anshanno
  • 344
  • 4
  • 21
2
votes
1 answer

Pandas DatetimeIndex indexing dtype: datetime64 vs Timestamp

Indexing a pandas DatetimeIndex (with dtype numpy datetime64[ns]) returns either: another DatetimeIndex for multiple indices a pandas Timestamp for single index The confusing part is that Timestamps do not equal np.datetime64, so that: import…
user3217125
  • 579
  • 5
  • 12
2
votes
3 answers

Python pandas generating first day of month from array of datetime

I am trying to obtain the first day of month from array of datetime i.e. change all days to 1 and all hours to 0: import pandas as pd z1 = [datetime(2025, 10, 1, 3, 0),datetime(2025, 1, 6, 7,…
Zanam
  • 4,607
  • 13
  • 67
  • 143
2
votes
0 answers

How to Group Boxplots by Day in Dataframe

So I have data which looks like this: Observed WRF 2014-06-28 12:00:00 0.000000 1.823554 2014-06-28 13:00:00 0.000000 1.001567 2014-06-28 14:00:00 0.000000 0.309840 2014-06-28 15:00:00 0.000000 0.889811 2014-06-28…
Colorful Ed
  • 143
  • 2
  • 12
2
votes
1 answer

Assign time element of DateTimeIndex to new column

im working with the below DataFrame and want to access only the time (not date) of my DateTimeIndex: idle wheel Induce wheel axial radial tiempo 5/30/2016 19:37:46 -1,099.12 -1,048.78 -477.13 5/30/2016 19:37:47 …
tomzko
  • 77
  • 5
2
votes
1 answer

Pivot table not creating with datetimeindex from dataframe

I'm having trouble creating a pivot table from a dataframe with a datetimeindex as the index. Editing to show complete code The code in question is unit1 = ["U1", "U1", "U1", "U1", "U1", "U1"] name1 = ["fn ln", "fn ln2", "fn ln3", "fn ln4", "fn…
cryptoref
  • 413
  • 1
  • 7
  • 17
2
votes
2 answers

How to get all day data from index matching one day

I have a dataframe df1 indexed by datetime with entries every minutes for weeks sample: SAMPLE_TIME Bottom Top Out state 0 2015-07-15 16:41:56 …
InsaneBot
  • 2,422
  • 2
  • 19
  • 31
2
votes
2 answers

Selecting rows with specified days in datetimeindex dataframe - Pandas

I have a dataframe with datetimeindex. I only need those rows whose index belong to days specified in a list e.g. [1,2] for Monday and Tuesday. Can this be possible in pandas in a single line of code.
Dark Light
  • 1,210
  • 11
  • 19