[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572433-105":53,"doc-detail-572433-en":127},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","pandas-cheat-sheet-data-wrangling","Pandas - Cheat Sheet - Data Wrangling","","Pandas Cheat Sheet focuses on data wrangling workflows and common operations in the pandas ecosystem. It covers creating DataFrames, method chaining, tidy data principles, and practical row and column filtering. The sheet explains selection via query(), df.loc/df.iloc, and single-value access with at/iat. It also summarizes logical comparisons, regex matching examples, grouping with groupby, and key summarization utilities like value_counts, describe, info, and memory usage.",{"@graph":63,"@context":119},[64,80,102],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/pandas-cheat-sheet-data-wrangling/572433/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/pandas-cheat-sheet-data-wrangling/572433.png","ImageObject",442,249,{"name":88,"@type":89},"Danger Angel","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-21","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",7,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"How can you create a DataFrame with specified columns and index in pandas?","Question",{"text":109,"@type":110},"Use pd.DataFrame with either a dictionary of column lists or a 2D list, and pass index and columns arguments to control structure.","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"How do query() and loc/iloc differ for filtering rows?",{"text":114,"@type":110},"query() filters rows using Boolean expressions, while df.loc[] and df.iloc[] select by labels or positional indexes, supporting both row and column slicing.",{"name":116,"@type":107,"acceptedAnswer":117},"What are the key functions for summarizing grouped and ungrouped data?",{"text":118,"@type":110},"value_counts, describe, info, memory usage, and dtypes provide dataset-level summaries; groupby enables applying summary functions per group.","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},572433,1792021558,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":130,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":76,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":9},962090769052,"https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","Data Wrangling  \nwith pandas Cheat Sheet  \n[http://pandas.pydata.org](http://pandas.pydata.org)[ ](http://pandas.pydata.org)Pandas API Reference Pandas  User Guide  \n\n| Creating DataFrames |\n| --- |\n| a b c 1 4 7 10 2 5 8 11 3 6 9 12\u003Cbr>df = pd.DataFrame (\u003Cbr>{\"a\" : [4, 5, 6],\"b\" : [7, 8, 9],\u003Cbr>\"c\" : [10, 11, 12]}, index = [1, 2, 3])\u003Cbr>Specify values for each column.\u003Cbr>df = pd.DataFrame (\u003Cbr>[[4, 7, 10],\u003Cbr>[5, 8, 11],\u003Cbr>[6, 9, 12]],\u003Cbr>index=[1, 2, 3],\u003Cbr>columns=['a', 'b', 'c'])\u003Cbr>Specify values for each row.\u003Cbr>a b c N v D 1 4 7 10 2 5 8 11 e 2 6 9 12\u003Cbr>df = pd.DataFrame (\u003Cbr>{\"a\" : [4 ,5, 6],\"b\" : [7, 8, 9],\"c\" : [10, 11, 12]},\u003Cbr>index = pd.MultiIndex.from tuples ([('d', 1), ('d', 2),\u003Cbr>('e', 2)], names=['n', 'v']))\u003Cbr>Create DataFrame with a MultiIndex |\n\n| Method Chaining |\n| --- |\n| Most pandas methods return a DataFrame so that another pandas method can be applied to the result. This improves readability of code.\u003Cbr>df = (pd.melt (df)\u003Cbr>.rename (columns={'variable':'var','value':'val'})\u003Cbr>.query ('val >= 200')) |\n\nTidy Data – A foundation for wrangling in pandas  \ndInaatatidyset:Each variable is save  in its own column  \nEach observation is  \nTidy data complements pandas’s vectorized operations. pandas will automatically preserve observations as you manipulate variables. No other format works as intuitively with pandas.  \nsaved in its own row  \nM * A  \ndf [df.Length > 7]  \nExtract rows that meet logical criteria.  \ndf.drop duplicates ()  \nRemove duplicate rows (only considers columns)  \ndf.sample (frac=0.5)  \nRandomly select fraction of rows.  \ndf.sample (n=10) Randomly select n rows.  \ndf.nlargest (n, 'value')  \nSelect and order top n entries.  \ndf.nsmallest (n, 'value')  \nSelect and order bottom n entries.  \ndf.head (n)  \nSelect first n rows.  \ndf.tail (n)  \nSelect last n rows.  \n.  \ndf[['width', 'length', 'species']]  \nSelect multiple columns with specific names. df['width'] or df.width  \nSelect single column with specific name. df.filter (regex='regex')  \nSelect columns whose name matches regular expression regex.  \nUsing query  \nquery() allows Boolean expressions for filtering rows.  \ndf.query ('Length > 7')  \ndf.query ('Length > 7 and Width \u003C 8') df.query ('Name.str.startswith(\"abc\")', engine=\"python\")  \nUse df.loc[] and df.iloc[] to select only rows, only columns or both.  \n[Use](Use df.at)[ df.at](Use df.at)[] and df.iat[] to access a single value by row and column.  \nFirst index selects rows, second index columns.  \ndf.iloc [10:20]  \nSelect rows 10-20.  \ndf.iloc [:, [1, 2, 5]]  \nSelect columns in positions 1, 2 and 5 (first column is 0) .  \ndf.loc [:, 'x2':'x4']  \nSelect all columns between x2 and x4 (inclusive) .  \ndf.loc [df['a'] > 10, ['a', 'c']]  \nSelect rows meeting logical condition, and only the specific columns .  \ndf.iat [1, 2] Access single value by index [df.](df.at)[at](df.at)[4, 'A'] Access single value by label  \n\n| Logic in Python (and pandas) |  |  |\n| --- | --- | --- |\n| \u003C | Less than != | Not equal to |\n| > | Greater than df.column.isin (values) | Group membership |\n| == | Equals pd.isnull (obj) | Is NaN |\n| \u003C= | Less than or equals pd.notnull (obj) | Is not NaN |\n| >= | Greater than or equals &,|,~,^,df.any(),df.all() | Logical and, or, not, xor, any, all |\n\n| regex (Regular Expressions) Examples |  |\n| --- | --- |\n| '\\ . ' | Matches strings containing a period ' . ' |\n| 'Length$' | Matches strings ending with word 'Length' |\n| '^Sepal' | Matches strings beginning with the word 'Sepal' |\n| '^x[1-5]$' | Matches strings beginning with 'x' and ending with 1,2,3,4,5 |\n| '^(?!Species$) .*' | Matches strings except the string 'Species' |\n\nCheatsheet for pandas ([http://pandas.pydata.org/](http://pandas.pydata.org/ originally written by Irv Lustig)[ originally written by Irv Lustig](http://pandas.pydata.org/ originally written by Irv Lustig),  Princeton Consultants, inspired by Rstudio Data Wrangling Cheatsheet  \nGroup Data  \n|  |  |  |\n| --- | --- | --- |\n|  |  |  |\n|  |  |  |\n|  |  |  |","cbCaiq54lOwY1xov","https://ap.wps.com/l/cbCaiq54lOwY1xov","pdf",398312,"English","# Creating DataFrames\n# Method Chaining\n# Tidy Data\n# Data Selection and Filtering\n## Using query\n## Selecting with loc/iloc and at/iat\n# Logic and Regular Expressions\n# Group Data\n# Summarize Data","[{\"question\":\"How can you create a DataFrame with specified columns and index in pandas?\",\"answer\":\"Use pd.DataFrame with either a dictionary of column lists or a 2D list, and pass index and columns arguments to control structure.\"},{\"question\":\"How do query() and loc/iloc differ for filtering rows?\",\"answer\":\"query() filters rows using Boolean expressions, while df.loc[] and df.iloc[] select by labels or positional indexes, supporting both row and column slicing.\"},{\"question\":\"What are the key functions for summarizing grouped and ungrouped data?\",\"answer\":\"value_counts, describe, info, memory usage, and dtypes provide dataset-level summaries; groupby enables applying summary functions per group.\"}]","Pandas - Cheat Sheet - Data Wrangling | PDF",1791927389]