# Path: rest_pandas/serializers.py
# class PandasUnstackedSerializer(PandasSerializer):
#     """
#     Pivots dataframe so commonly-repeating values are across the top in a
#     multi-row header.  Intended for use with e.g. time series data, where the
#     header includes metadata applicable to each time series.
#     (Use with wq/chart.js' timeSeries() function)
#     """
#     index_none_value = '-'
#     wq_chart_type = 'timeSeries'
# 
#     def get_index(self, dataframe):
#         """
#         Include header fields in initial index for later unstacking
#         """
#         return self.get_index_fields() + self.get_header_fields()
# 
#     def transform_dataframe(self, dataframe):
#         """
#         Unstack the dataframe so header fields are across the top.
#         """
#         dataframe.columns.name = ""
# 
#         for i in range(len(self.get_header_fields())):
#             dataframe = dataframe.unstack()
# 
#         # Remove blank rows / columns
#         dataframe = dataframe.dropna(
#             axis=0, how='all'
#         ).dropna(
#             axis=1, how='all'
#         )
#         return dataframe
# 
#     def get_header_fields(self):
#         """
#         Series metadata fields for header (first few rows)
#         """
#         return self.get_meta_option('unstacked_header')
# 
# Path: tests/testapp/models.py
# class TimeSeries(models.Model):
#     date = models.DateField()
#     value = models.FloatField()
# 
#     objects = DataFrameManager()
# 
# class MultiTimeSeries(models.Model):
#     # Header
#     series = models.CharField(max_length=5)
# 
#     # Index
#     date = models.DateField()
# 
#     # Values
#     value = models.FloatField()
# 
# class ComplexTimeSeries(models.Model):
#     # Header
#     site = models.CharField(max_length=5)
#     parameter = models.CharField(max_length=5)
#     units = models.CharField(max_length=5, null=True, blank=True)
# 
#     # Index
#     date = models.DateField()
#     type = models.CharField(max_length=10)
# 
#     # Values
#     value = models.FloatField()
#     flag = models.CharField(max_length=1, null=True, blank=True)
# 
# class CustomIndexSeries(models.Model):
#     code = models.SlugField(primary_key=True)
#     value = models.FloatField()


from rest_framework.serializers import ModelSerializer
from rest_framework import serializers
from rest_pandas import PandasUnstackedSerializer
from .models import (
    TimeSeries, MultiTimeSeries, ComplexTimeSeries, CustomIndexSeries,
)


class TimeSeriesSerializer(ModelSerializer):
    date = serializers.DateField(format=None)

    class Meta:
        model = TimeSeries
        fields = '__all__'


class TimeSeriesNoIdSerializer(TimeSeriesSerializer):
    class Meta:

# Path: rest_pandas/serializers.py
# class PandasUnstackedSerializer(PandasSerializer):
#     """
#     Pivots dataframe so commonly-repeating values are across the top in a
#     multi-row header.  Intended for use with e.g. time series data, where the
#     header includes metadata applicable to each time series.
#     (Use with wq/chart.js' timeSeries() function)
#     """
#     index_none_value = '-'
#     wq_chart_type = 'timeSeries'
# 
#     def get_index(self, dataframe):
#         """
#         Include header fields in initial index for later unstacking
#         """
#         return self.get_index_fields() + self.get_header_fields()
# 
#     def transform_dataframe(self, dataframe):
#         """
#         Unstack the dataframe so header fields are across the top.
#         """
#         dataframe.columns.name = ""
# 
#         for i in range(len(self.get_header_fields())):
#             dataframe = dataframe.unstack()
# 
#         # Remove blank rows / columns
#         dataframe = dataframe.dropna(
#             axis=0, how='all'
#         ).dropna(
#             axis=1, how='all'
#         )
#         return dataframe
# 
#     def get_header_fields(self):
#         """
#         Series metadata fields for header (first few rows)
#         """
#         return self.get_meta_option('unstacked_header')
# 
# Path: tests/testapp/models.py
# class TimeSeries(models.Model):
#     date = models.DateField()
#     value = models.FloatField()
# 
#     objects = DataFrameManager()
# 
# class MultiTimeSeries(models.Model):
#     # Header
#     series = models.CharField(max_length=5)
# 
#     # Index
#     date = models.DateField()
# 
#     # Values
#     value = models.FloatField()
# 
# class ComplexTimeSeries(models.Model):
#     # Header
#     site = models.CharField(max_length=5)
#     parameter = models.CharField(max_length=5)
#     units = models.CharField(max_length=5, null=True, blank=True)
# 
#     # Index
#     date = models.DateField()
#     type = models.CharField(max_length=10)
# 
#     # Values
#     value = models.FloatField()
#     flag = models.CharField(max_length=1, null=True, blank=True)
# 
# class CustomIndexSeries(models.Model):
#     code = models.SlugField(primary_key=True)
#     value = models.FloatField()


# Path: tests/testapp/serializers.py
from rest_framework.serializers import ModelSerializer
from rest_framework import serializers
from rest_pandas import PandasUnstackedSerializer
from .models import (
    TimeSeries, MultiTimeSeries, ComplexTimeSeries, CustomIndexSeries,
)



class TimeSeriesSerializer(ModelSerializer):
    date = serializers.DateField(format=None)

    class Meta:
        model = TimeSeries
        fields = '__all__'


class TimeSeriesNoIdSerializer(TimeSeriesSerializer):
    class Meta:

        model = TimeSeries