在使用Spyder时,有可能要查询某个函数或者某个模块的具体用法。
1、要查看模块的作用说明、简介,可以直接在交互区直接输入:
print(模块名.__doc__)
例如:要查看pandas的介绍
In[1]:print(pd.__doc__) pandas-apowerfuldataanalysisandmanipulationlibraryforPython ===================================================================== **pandas**isaPythonpackageprovidingfast,flexible,andexpressivedata structuresdesignedtomakeworkingwith"relational"or"labeled"databoth easyandintuitive.Itaimstobethefundamentalhigh-levelbuildingblockfor doingpractical,**realworld**dataanalysisinPython.Additionally,ithas thebroadergoalofbecoming**themostpowerfulandflexibleopensourcedata analysis/manipulationtoolavailableinanylanguage**.Itisalreadywellon itswaytowardthisgoal. MainFeatures ------------- Herearejustafewofthethingsthatpandasdoeswell: -Easyhandlingofmissingdatainfloatingpointaswellasnon-floating pointdata -Sizemutability:columnscanbeinsertedanddeletedfromDataFrameand higherdimensionalobjects -Automaticandexplicitdataalignment:objectscanbeexplicitlyaligned toasetoflabels,ortheusercansimplyignorethelabelsandlet `Series`,`DataFrame`,etc.automaticallyalignthedataforyouin computations -Powerful,flexiblegroupbyfunctionalitytoperformsplit-apply-combine operationsondatasets,forbothaggregatingandtransformingdata -Makeiteasytoconvertragged,differently-indexeddatainotherPython andNumPydatastructuresintoDataFrameobjects -Intelligentlabel-basedslicing,fancyindexing,andsubsettingoflarge datasets -Intuitivemergingandjoiningdatasets -Flexiblereshapingandpivotingofdatasets -Hierarchicallabelingofaxes(possibletohavemultiplelabelspertick) -RobustIOtoolsforloadingdatafromflatfiles(CSVanddelimited), Excelfiles,databases,andsaving/loadingdatafromtheultrafastHDF5 format -Timeseries-specificfunctionality:daterangegenerationandfrequency conversion,movingwindowstatistics,movingwindowlinearregressions, dateshiftingandlagging,etc.
2、想知道某个函数的用法可以使用:
help(函数名)
例如:要查询pandas的fillna的使用方法
In[2]:help(x.fillna) Helponmethodfillnainmodulepandas.core.frame: fillna(value=None,method=None,axis=None,inplace=False,limit=None,downcast=None,**kwargs)methodofpandas. core.frame.DataFrameinstance FillNA/NaNvaluesusingthespecifiedmethod Parameters ---------- value:scalar,dict,Series,orDataFrame Valuetousetofillholes(e.g.0),alternatelya dict/Series/DataFrameofvaluesspecifyingwhichvaluetousefor eachindex(foraSeries)orcolumn(foraDataFrame).(valuesnot inthedict/Series/DataFramewillnotbefilled).Thisvaluecannot bealist. method:{'backfill','bfill','pad','ffill',None},defaultNone MethodtouseforfillingholesinreindexedSeries pad/ffill:propagatelastvalidobservationforwardtonextvalid backfill/bfill:useNEXTvalidobservationtofillgap axis:{0or'index',1or'columns'} inplace:boolean,defaultFalse IfTrue,fillinplace.Note:thiswillmodifyany otherviewsonthisobject,(e.g.ano-copysliceforacolumnina DataFrame). limit:int,defaultNone Ifmethodisspecified,thisisthemaximumnumberofconsecutive NaNvaluestoforward/backwardfill.Inotherwords,ifthereis agapwithmorethanthisnumberofconsecutiveNaNs,itwillonly bepartiallyfilled.Ifmethodisnotspecified,thisisthe maximumnumberofentriesalongtheentireaxiswhereNaNswillbe filled.Mustbegreaterthan0ifnotNone. downcast:dict,defaultisNone adictofitem->dtypeofwhattodowncastifpossible, orthestring'infer'whichwilltrytodowncasttoanappropriate equaltype(e.g.float64toint64ifpossible) SeeAlso -------- reindex,asfreq Returns ------- filled:DataFrame原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容