-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pandas): generate series and dataframes from class init rather th…
…an function This looks cleaner and is more in line with other pandas extensions
- Loading branch information
1 parent
1ecc218
commit f557b4f
Showing
5 changed files
with
147 additions
and
138 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
"""ladybug-pandas library.""" | ||
|
||
from .dataframe import dataframe_from_collections, dataframe_from_epw | ||
from .series import series_from_collection | ||
from .dataframe import DataFrame | ||
from .series import Series | ||
|
||
from .accessors.ladybug import LadybugSeriesAccessor, LadybugDataFrameAccessor | ||
from .accessors.psychrometrics import PsychrometricsAccessor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,42 @@ | ||
import pandas as pd | ||
from .extension_types.arraytype import LadybugArrayType | ||
|
||
def series_from_collection(data_collection) -> pd.Series: | ||
"""Generate a pandas Series from a Ladybug Data Collection | ||
class Series: | ||
|
||
Arguments: | ||
data_collection {ladybug._datacollectionbase.BaseCollection} -- An instance of a ladybug data collection | ||
def __new__(cls, data_collection) -> pd.Series: | ||
"""Generate a pandas Series from a Ladybug Data Collection | ||
Returns: | ||
pd.Series -- A pandas Series of type Ladybug Array | ||
""" | ||
Example: | ||
.. code-block:: python | ||
array = LadybugArrayType._from_data_collection(data_collection) | ||
import ladybug_pandas as lbp | ||
from ladybug.wea import Wea | ||
from ladybug.location import Location | ||
location = Location( | ||
city='Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu', | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sariths
|
||
state='Wales', | ||
country='United Kingdom', | ||
latitude=-40.3500, | ||
longitude=176.5500, | ||
time_zone=12 | ||
) | ||
wea = Wea.from_ashrae_clear_sky(location=location) | ||
series = lbp.Series(wea.direct_normal_irradiance) | ||
Arguments: | ||
data_collection {ladybug._datacollectionbase.BaseCollection} -- An instance of a ladybug data collection | ||
Returns: | ||
pd.Series -- A pandas Series of type Ladybug Array | ||
""" | ||
|
||
array = LadybugArrayType._from_data_collection(data_collection) | ||
|
||
return pd.Series( | ||
data=array, | ||
index=data_collection.datetimes | ||
) | ||
|
||
return pd.Series( | ||
data=array, | ||
index=data_collection.datetimes | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This one is for you @sariths