Mathematica and the Wolfram Language provide an integrated environment for sophisticated programming, making them the ideal tools for calculus, data visualization, machine learning, and more. But how about using Wolfram as the linchpin for organizing data? In this book, Professor Seth J. Chandler, an award-winning, 30-year user of the Wolfram Language, guides intermediate users from simple cases to data in the wild and shows how each can be fed into the full range of Wolfram Language functionality. It's both a conceptual and practical approach filled with annotated examples.
Want to know more about associations or the organization and presentation of datasets? This book shows how it's done. Want to organize or reduce data in the Wolfram Language similarly to the way one might use SQL, pandas in Python, or dplyr in R's tidyverse? This book shows how to simplify data processing and go beyond what is possible with other tools using the Query function. It also explores how to import information from the places real-world data is most likely to be found: CSV, Excel, or JSON files.
Use Query both as a tutorial and as a reference. Read it cover-to-cover doing the exercises or dip in to look up specific data-wrangling tasks. Augmenting the underlying power of the Wolfram Language with the techniques taught in this book puts you at the forefront of innovative data analysis.Contents
Purpose · Audience · How to Read This Book · Chapter Roadmap · Version · Front End · Repositories · Conventions · Exercises · Technical Notes · A Little about Me
Data Structures and Functions
The Mathematica Expression · The Part Function · The Function · The List · Levels · Position: Part and Level · Functional Programming Constructs · Common Operations on Lists · A Sample Problem Using "Old-School" Wolfram Language Methods · Conclusion
A Home-Brewed Indexed Data Structure · The Association · Using Part with Association · Functions on Associations · Associations inside Other Expressions · Position on Association · KeyTake and KeyDrop · Lookup · Building Associations · Functional Programming Constructs Used on Associations · Apply and Transpose · KeyMap · KeyValueMap · The KeyReplace Resource Function · Select · GatherBy · GroupBy · Associations as Functions · Putting It Together: More Complex Operations Using Operators and Composition
Query Structure · Order of Operations in Query · Four Complications · Solve Sample Problems with Query · How to Do Nothing: All or Identity · Queries with Deeply Nested Datasets · Functions That Create Queries · Debugging Queries That Go Wrong
Introduction · Inside the Datasets · Dataset Presentation
Introduction · Get the Dimensions of a Dataset · Rename All of the Columns · Rename Just Some of the Columns · Sort Rows and Columns · Sort Groupings · Sample the Rows · Replace Some Key-Value Pairs in an Association: The Association Override Feature · Keep and Drop Rows or Columns · Join Columns Based on Precomputed Data · Join a Column to a Dataset Based on Values in the Existing Columns · Change the Value of an Existing Column: Row-Wise · Add Row Headers (Indexing) · Delete Row Headers · Turn Row Headers into Columns · Give a Column Orientation to a Dataset · Give a Row Orientation to a Dataset · Transpose Datasets and the Double Transpose Trick · Defer Operation of a Descending Operator
Introduction · Recipe 1: Use Column Aggregates to Derive New Columns · Recipe 2: Aggregate Single Measures by Group · Recipe 3: Make the Keys in Each Row of Data Identical · Recipe 4: Create Multiple Aggregate Measures of Grouped Data · Recipe 5: "Cross Tabulate" Data · Recipe 6: Get Row and/or Column Aggregates of Data · Recipe 7: Prepare Data for Statistical Analysis Functions · Recipe 8: Prepare Data for Machine Learning Functions · Recipe 9: Combine Graphics with Query · Recipe 10: Retrieve Information from the Wolfram Data Repository · Recipe 11: Flatten Hierarchy in a Dataset or Convert One Dataset into Multiple Related Datasets · Recipe 12: Create Overlapping Sets of Data
Import and Export
Introduction · The "Format" and "Elements" Concept · Using the WXF Format · Using the Text Export Format · Using the CSV Export Format · Using the Excel (XLS, XLSX) Format · Using the JSON Format · Using the ZIP Format · Using the Google Sheets Format
Answers to Exercises
Index Related Topics