本文整理匯總了Python中pandas.core.frame.DataFrame.select方法的典型用法代碼示例。如果您正苦於以下問題:Python DataFrame.select方法的具體用法?Python DataFrame.select怎麽用?Python DataFrame.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.core.frame.DataFrame
的用法示例。
在下文中一共展示了DataFrame.select方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_daily_normals
# 需要導入模塊: from pandas.core.frame import DataFrame [as 別名]
# 或者: from pandas.core.frame.DataFrame import select [as 別名]
def get_daily_normals(self, start_date = None, end_date = None, stamp_year = 2001):
"""
:type start_date: datetime.datetime
:type end_date: datetime.datetime
:rtype : list , list
"""
self.stamp_day_dates = pandas.DatetimeIndex(start = datetime(stamp_year,1,1), end = date(stamp_year, 12, 31),
freq = pandas.datetools.offsets.Day())
if start_date is None:
start_date = self.time[0]
if end_date is None:
end_date = self.time[-1]
di = pandas.DatetimeIndex(data = self.time)
df = DataFrame(data = self.data, index = di, columns=["values",])
df = df.select( lambda d: start_date <= d <= end_date )
df_mean = df.groupby(by = lambda d: (d.day, d.month)).mean()
return self.stamp_day_dates, df_mean.ix[[ (d.day, d.month) for d in self.stamp_day_dates] ,"values"]
示例2: main
# 需要導入模塊: from pandas.core.frame import DataFrame [as 別名]
# 或者: from pandas.core.frame.DataFrame import select [as 別名]
def main():
# stations = cehq_station.read_grdc_stations(st_id_list=["2903430", "2909150", "2912600", "4208025"])
selected_ids = ["08MH001", "08NE074", "08NG065", "08NJ013", "08NK002", "08NK016",
"08NL004", "08NL007", "08NL024", "08NL038", "08NN002"]
stations = cehq_station.load_from_hydat_db(natural=True, province="BC", selected_ids=selected_ids)
stations_to_mp = None
import matplotlib.pyplot as plt
# labels = ["CanESM", "MPI"]
# paths = ["/skynet3_rech1/huziy/offline_stfl/canesm/discharge_1958_01_01_00_00.nc",
# "/skynet3_rech1/huziy/offline_stfl/mpi/discharge_1958_01_01_00_00.nc"]
#
# colors = ["r", "b"]
# labels = ["ERA", ]
# colors = ["r", ]
# paths = ["/skynet3_rech1/huziy/arctic_routing/era40/discharge_1958_01_01_00_00.nc"]
labels = ["Glacier-only", "All"]
colors = ["r", "b"]
paths = [
"/skynet3_exec2/aganji/glacier_katja/watroute_gemera/discharge_stat_glac_00_99_2000_01_01_00_00.nc",
"/skynet3_exec2/aganji/glacier_katja/watroute_gemera/discharge_stat_both_00_992000_01_01_00_00.nc"]
start_year_current = 2000
end_year_current = 2013
plot_future = False
start_year_future = 2071 # ignored when plot future is false
end_year_future = 2100
if not plot_future:
start_year = start_year_current
end_year = end_year_current
else:
start_year = start_year_future
end_year = end_year_future
stations_filtered = []
for s in stations:
# Also filter out stations with small accumulation areas
if s.drainage_km2 < 1000:
continue
if s.latitude > 49.4:
continue
# Filter stations with data out of the required time frame
year_list = s.get_list_of_complete_years()
if max(year_list) < start_year or min(year_list) > end_year:
continue
stations_filtered.append(s)
stations = stations_filtered
min_lon = min(s.longitude for s in stations)
stations = [s for s in stations if s.longitude == min_lon]
print("Retained {} stations.".format(len(stations)))
sim_to_time = {}
monthly_dates = [datetime(2001, m, 15) for m in range(1, 13)]
fmt = FuncFormatter(lambda x, pos: num2date(x).strftime("%b")[0])
locator = MonthLocator()
fig = plt.figure()
axes = []
row_indices = []
col_indices = []
ncols = 1
shiftrow = 0 if len(stations) % ncols == 0 else 1
nrows = len(stations) // ncols + shiftrow
shared_ax = None
gs = gridspec.GridSpec(ncols=ncols, nrows=nrows)
for i, s in enumerate(stations):
row = i // ncols
col = i % ncols
row_indices.append(row)
col_indices.append(col)
#.........這裏部分代碼省略.........