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
0
votes
0 answers

Adding data based on datetime index

I have the below code dateseries=pd.date_range('1996-10-31','2019-01-05',freq='B') df1['Date']=pd.DataFrame(dateseries,columns=['Date']) I want to add a column for sum for each date in this dataframe (df) from another dataframe (say df2, that has…
0
votes
0 answers

How to iterate over Datetime Index on a Panda DF

I have a simple(and long) Panda DF with Datetime Index and Prices, I am trying to create a new Column ['ewm_12'] which pick 11 previous rows every 120 minutes appends current price and calculates the ewm I am trying to do it in a vectorized fashion…
Mcavalca
  • 15
  • 3
0
votes
1 answer

Plotting a subplot- Python

I have been trying to achieve something like this: Example So far this is what I have tried: crimes.Month = pd.to_datetime(crimes.Month, format='%Y/%m') crimes.index = pd.DatetimeIndex(crimes.Month) import numpy as np crimes_count_date =…
Ammie
  • 15
  • 1
  • 5
0
votes
2 answers

Pandas - Get all rows between two dates, but only specific weekdays, and time periods

Say I have a dataframe with that looks like the following: usage_price 2017-04-01 00:00:00 1 2017-04-01 00:30:00 1 2017-04-01 01:00:00 1 2017-04-01 01:30:00 1 2017-04-01 02:00:00 …
Darkstarone
  • 4,590
  • 8
  • 37
  • 74
0
votes
0 answers

Not using the datetime module and even then get this, TypeError: 'DatetimeIndex'

Hi why do I get this error and how do I correct it? File "", line 1, in range(6,31,7) TypeError: 'DatetimeIndex' object is not callable weekend_prime = [] weekends = [] weekday_prime=[] def…
user2922935
  • 439
  • 4
  • 12
0
votes
0 answers

efficient way to compute pandas DatetimeIndex with censored dates

So I can do this by brute force, but it's painfully slow so I'm sure I'm missing something. Let's say that I want to create a (daily) DatetimeIndex of fixed length, say 15 days, but there are some caveats: if the 15-day index ends on a weekend,…
Matt
  • 183
  • 1
  • 6
0
votes
0 answers

Issue with pandas.setindex() to datetime

I have a pandas dateframe with stock market data. There is a date column ('date'). When trying to access a date using a string, I receive: KeyError: 'the label [1981-02-17 00:00:00] is not in the [index]' I explicitly set the index to be a datetime…
pawlactb
  • 109
  • 1
  • 9
0
votes
1 answer

Python Pandas Resample Gives False instead of NaN or NA

I'm using pandas dataframe with datetime index to work with timeseries data. Since I'm working with observed data there can be quite no. of missing values. However I wanted to resample the observed timeseries as follows, freq = 'H' obs_mean =…
Thilina Madumal
  • 101
  • 1
  • 4
0
votes
1 answer

How can I make a table with a date range labeling weekdays and weekends (joinable by date) in python?

I've never worked with DataTimeIndex. It's giving me a headache as everything I normally would try is not working. I've tried converting to datetime and I'm still unable to just make a weekday column using date.weekday or .dayofweek. Can someone…
Analysa
  • 91
  • 1
  • 8
0
votes
1 answer

Pandas index setting and importing values to columns

I am new to Python and working my way through my crawling project. I have two questions regarding few pandas module. Below is my data table "js" apple banana period 2017-01-01 100.00000 22.80130 2017-02-01 94.13681 …
EJ Kang
  • 455
  • 2
  • 5
  • 17
0
votes
0 answers

Key error when indexing two Panda DataFrames with same index

Python 2.7, spyder, all packages installed by Anaconda. The code runs good befor upgrade to pandas 0.20.3 Trying to index two dataframes, days and udly, with unicode string date '2017-09-13' they both have same index udly.index[-1] Out[13]:…
T.young
  • 23
  • 5
0
votes
1 answer

Slicing Pandas datetime starting from a given date

I want to mix two different datasets. One has datetime as index and the other one as a column. In the first dataset, given a begin_date, in the first dataset, I want to slice 5 days starting from begin_date and then combine two datasets. date …
mk_sch
  • 1,060
  • 4
  • 16
  • 31
0
votes
0 answers

Python Pandas: Converting Dataframes and setting Indexes

I have to do the tasks below, but some parts do not work out properly. Here are the steps: Converting a dataframe with unix timestamps to a dataframe with datetime values, works with the following code: datetime_df = pd.to_datetime(unix_df,…
sunwarr10r
  • 4,420
  • 8
  • 54
  • 109
0
votes
1 answer

Set DateTimeIndex format when using TimeGroupper

In the following snippet I want to do the format transformation inplace without having to keep another temporary variable (df) df = other_df.set_index('datetime_created').groupby(pd.TimeGrouper("M")).aggregate({...complex dict...}) df.index =…
Flo
  • 1,367
  • 1
  • 13
  • 27
0
votes
2 answers

How to update the value of DatetimeIndex of a single row in a pandas DataFrame?

In a python pandas DataFrame, I would like to update the value of the index in a single row (preferably in-place as the DataFrame is quite large). The index is DatetimeIndex and the DataFrame may contain several columns. For instance: In [1]: import…
Pedia
  • 1,432
  • 2
  • 11
  • 17
1 2 3
21
22