Notebook resampling

I’m importing a csv file to a notebook and are currently resampling TSV values to 15 min.
in that process, Is there a way to apply “avg” to one column and “max” to another?

Hi @Lars_Andersson,

I’m a bit confused by your question. Are you converting from a CSV to a TSV, or vice versa? I am interpreting this as though you are aggregating values in 15-minute durations, and are looking for a way to get the average and the maximum of all of the aggregated values, is that correct? Any screenshots or further descriptions of your use case would also be beneficial.

Thanks!
Julia

the notebooks input file is a csv file based on TSV data.
The notebook resamples to 15 minutes averages for all the values as it is now.
But one of the values is actually a counter, so I would like to know the max value/15 min instead of avg.

Hi @Lars_Andersson,

Losant does not aggregate data inputs, and aggregations should be occurring within the Notebook. Are you calculating the average within your Notebook? If so, you will need to calculate the maximum value within your Notebook code as well.

Thanks!
Julia

That’s what I’m trying to do, but couldn’t find any good info if I could apply avg to one column and max to another in the same resample command.

Hey @Lars_Andersson,

For help with building notebooks, we put together a list of resources for you here:

Overall, what you would need to do is take the input CSV and turn it into a pandas data frame.

import pandas as pd

input_dir = os.path.join(os.environ['INPUT_DIR'])

dataset = pd.read_csv(input_dir, 'data.csv')

Once as pandas data frame, there is a ton more you can do with the data. For example, the pandas library has a mean function to get the average of a column. Once you’re in Notebook land, the expectation is that you would perform all of the data calculations and manipulations within the Notebooks.

I’d recommend reading through some pandas tutorials/guides. Here are some good ones that may help:


https://github.com/pandas-dev/pandas/blob/master/doc/cheatsheet/Pandas_Cheat_Sheet.pdf

http://www.swegler.com/becky/blog/2014/08/06/useful-pandas-snippets/