本文整理匯總了Python中pandas.core.frame.DataFrame.sort_values方法的典型用法代碼示例。如果您正苦於以下問題:Python DataFrame.sort_values方法的具體用法?Python DataFrame.sort_values怎麽用?Python DataFrame.sort_values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.core.frame.DataFrame
的用法示例。
在下文中一共展示了DataFrame.sort_values方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: zip
# 需要導入模塊: from pandas.core.frame import DataFrame [as 別名]
# 或者: from pandas.core.frame.DataFrame import sort_values [as 別名]
#print(shp)
#print(sc)
IDF = []
for item_sc in sc:
item_idf = math.log(item_sc)
IDF.append(item_idf)
#print(IDF)
TFIDF = [i * j for i, j in zip(TF, IDF)]
#print(TFIDF)
#print(header)
Dict_TFIDF={item_bank+'_hd':header, item_bank+'_ti':TFIDF}
df_TFIDF = DataFrame(Dict_TFIDF)
df_TFIDF1 = df_TFIDF.sort_values(item_bank+'_ti',ascending=False).reset_index(drop=True)
df_Bank = pd.concat([df_Bank,df_TFIDF1], axis=1)
print(df_Bank)
sum(TF.isnull())
df_Bank.花旗_ti[~df_Bank.花旗_ti.isnull()]
'''
# decision tree
# 讀入
ptt_cont = df()
X = ptt_cont.data
Y = ptt_cont.target
示例2: LineMesurer
# 需要導入模塊: from pandas.core.frame import DataFrame [as 別名]
# 或者: from pandas.core.frame.DataFrame import sort_values [as 別名]
#.........這裏部分代碼省略.........
self.current_df = lines_dataframe
self.line_to_Logdf()
#Otherwise return the data from the fit
else:
return self.fit_dict
def dazer_lineMeasuring(self, subWave, subFlux, wavelengths_list, lines_dataframe, Measuring_Method = 'lmfit'):
#Clear the dictionaries with the line data
self.fit_dict = Series(index = self.fitting_parameters, dtype=object)
#Get indeces of line_regions in spectrum wavelength
self.fit_dict.loc['idx0':'idx5'] = searchsorted(subWave, wavelengths_list)
self.fit_dict.loc['Wave1':'Wave6'] = wavelengths_list
#Calculation and plotting parameters of adjacent continuum
self.continuum_Regions(subWave, subFlux)
#Check if emission or absorption line as well as line mixture #WE SHOULD ONLY FEED HERE THE LINE REGION NOT ALL
self.check_GaussianMixture(subWave, Measuring_Method, lines_dataframe, force_check=True)
#Convert emission lines to gaussian equivalents
self.calculate_Intensity(subWave, subFlux, lines_dataframe)
#Save the fit:
if self.fit_dict.start_treatment:
#Update the data frame with the new data
self.line_to_Logdf()
#Sort the data frame
self.current_df.sort_values(['lambda_theo'], ascending=[True], inplace=True)
#Store data to dataframe
self.save_lineslog_dataframe(self.current_df, self.lineslog_df_address)
return
def continuum_Regions(self, subWave, subFlux, adjacent_continuum = True):
#Indeces from the continuum regions
idx1, idx2, idx3, idx4, idx5, idx6 = self.fit_dict[['idx0', 'idx1', 'idx2', 'idx3', 'idx4', 'idx5']]
#In this case we use adjacent regions to compute the continuum level
if adjacent_continuum == True:
#Region resolution
region_resolution = (subWave[-1] - subWave[0]) / len(subWave) #Should we save it?
#We generate arrays containing the wavelength and flux values from blue and red continuum
FluxCont_BothSides = concatenate((subFlux[idx1:idx2], subFlux[idx5:idx6]))
WaveCont_BothSides = concatenate((subWave[idx1:idx2], subWave[idx5:idx6]))
self.fit_dict['zerolev_width'] = region_resolution * len(WaveCont_BothSides)
#We generate and array with the standard deviation of the points on the left and the right #WARNING no se si esto esta bien
FluxError_BothSides = concatenate((std(subFlux[idx1:idx2]) * ones(len(subFlux[idx1:idx2])), std(subFlux[idx5:idx6]) * ones(len(subFlux[idx5:idx6]))))
#We perform a linear regresion taking into consideration the error in the flux #WARNING no se si esto esta bien
m_Continuum, n_continuum = Python_linfit(WaveCont_BothSides, FluxCont_BothSides, FluxError_BothSides, errors_output = False)
#We calculate the wavelength and flux at the middle region of each continuums for graphical purposes
self.fit_dict['Blue_wave_zerolev'] = (subWave[idx2] + subWave[idx1]) / 2
self.fit_dict['Red_wave_zerolev'] = (subWave[idx6] + subWave[idx5]) / 2