frequency of time series read with `read_csv`
See original GitHub issueI f I read a regular time series (with a fixed frequency) with read_csv, the resulting DataFrame has no freuqency.
In [82]: lines = ['2012-07-27T13:%02d, %d' % (min, index) for index, min in enumerate(range(1, 59))]
In [83]: input = StringIO.StringIO('\n'.join(lines))
In [84]: df = pd.read_csv(input, parse_dates=True, index_col=0, names='A')
In [85]: df.index
Out[85]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-07-27 13:01:00, ..., 2012-07-27 13:58:00]
Length: 58, Freq: None, Timezone: None
What I would like to have, is a possibility to set the frequency without resampling (or maybe read_csv could guess a frequency).
Issue Analytics
- State:
- Created 11 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Working with Time Series Data in R Importing Comma ...
The easiest way import data in .csv files into R is to use the R function read.csv(). To illustrate, consider the monthly adjusted...
Read more >Python Pandas: detecting frequency of time series
Show activity on this post. As you can see, the freq is None. I am wondering how can I detect the frequency of...
Read more >Intro to Time Series Data in R - Managing Date/Time Formats
This tutorial will demonstrate how to import a time series dataset stored in .csv format into R. It will explore data classes for...
Read more >How to handle time series data with ease? - Pandas
Resample a time series to another frequency The resample() method is similar to a groupby operation: it provides a time-based grouping, by using...
Read more >Working with Time Series | Python Data Science Handbook
In the final line, we've used one of the standard string format codes for printing dates ( "%A" ), which you can read...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
[Edit: corrected code snippet]
So what is the best way to set the frequency directly from the csv file dates?
And why can a infer_freq no be part of the read_csv function
This should not implemented using a
freq
argument if the intent is to pass in some numeric value. If theread_csv
function is called withparse_dates=True
then the date parsing function should attempt to determine the frequency on it’s own. It’s nonsense to expect the frequency to be known and passed to the parsing function. If the user can specify a value forfreq
they might as well reindex it after loading.Maybe I could understand adding a
determine_freq
boolean argument…Better still (for the user), parse the dates then try and determine the frequency anyway using
pd.infer_freq
. It took me quite a while to find this function; since it exists, I’m a little puzzled the date parser doesn’t use it by by default.