Python Tools for Scientists: An Introduction to Using Anaconda, JupyterLab, and Python’s Scientific Libraries
- Length: 472 pages
- Edition: 1
- Language: English
- Publisher: No Starch Press
- Publication Date: 2023-01-17
- ISBN-10: 1718502664
- ISBN-13: 9781718502666
- Sales Rank: #701691 (See Top 100 Books)
An introduction to the Python programming language and its most popular tools for scientists, engineers, students, and anyone who wants to use Python for research, simulations, and collaboration.
Doing Science with Python introduces readers to the most popular coding tools for scientific research, such as Anaconda, Spyder, Jupyter Notebooks, and JupyterLab, as well as dozens of important Python libraries for working with data, including NumPy, matplotlib, and pandas. No prior programming experience is required! You’ll be guided through setting up a professional coding environment, then get a crash course on programming with Python, and explore the many tools and libraries ideal for working with data, designing visualizations, simulating natural events, and more. In the book’s applied projects, you’ll use these tools to write programs that perform tasks like counting tree rings, creating an interactive science slideshow, and simulating the foraging patterns of animals.
Cover Page Title Page Copyright Page Dedication About the Author About the Technical Reviewer BRIEF CONTENTS CONTENTS IN DETAIL ACKNOWLEDGMENTS INTRODUCTION Why Python? Navigating This Book Part I: Setting Up Your Scientific Coding Environment Part II: A Python Primer Part III: The Anaconda Ecosystem Part IV: The Essential Libraries Appendix Updates and Errata Leaving Reviews PART I: SETTING UP YOUR SCIENTIFIC CODING ENVIRONMENT 1 INSTALLING AND LAUNCHING ANACONDA About Anaconda Installing Anaconda on Windows Installing Anaconda on macOS Installing Anaconda on Linux Getting to Know Anaconda Navigator Launching Navigator The Home Tab The Environments Tab The Learning Tab The Community Tab File Menu Summary 2 KEEPING ORGANIZED WITH CONDA ENVIRONMENTS Understanding Conda Environments Working with Conda Environments Using Navigator Launching Navigator Creating a New Environment Managing Packages Duplicating Environments Backing Up Environments Removing Environments Working with Conda Environments Using the Command Line Interface Launching the Command Line Interface Creating a New Environment Specifying an Environment’s Location Managing Packages Duplicating and Sharing Environments Restoring Environments Removing Environments Cleaning the Package Cache Summary 3 SIMPLE SCRIPTING IN THE JUPYTER QT CONSOLE Installing seaborn Installing and Launching the Jupyter Qt Console Using Navigator Installing and Launching the Jupyter Qt Console Using the CLI The Qt Console Controls Choosing a Syntax Style Using Keyboard Shortcuts Using Tabs and Kernels Printing and Saving Multiline Editing Summary 4 SERIOUS SCRIPTING WITH SPYDER Installing and Launching Spyder with Anaconda Navigator Installing and Launching Spyder Using the CLI Launching Spyder from the Start Menu Configuring the Spyder Interface Using Spyder with Environments and Packages The Naive Approach The Modular Approach Using Project Files and Folders Creating a Project in a New Directory Creating a Project in an Existing Directory Using the Project Pane The Help Pane The IPython Console Using the Console for Output and Plotting Using Kernels with the Console Clearing the Namespace The History Pane Special Consoles The Editor Pane Writing a Program Using the Editor Defining Code Cells Setting the Run Configuration Autocompleting Text The Code Analysis Pane The Variable Explorer Pane The Profiler Pane The Debugger Pane Summary 5 JUPYTER NOTEBOOK: AN INTERACTIVE JOURNAL FOR COMPUTATIONAL RESEARCH Installing Jupyter Notebook The Naive Approach The Modular Approach Your First Jupyter Notebook Creating Dedicated Project Folders Navigating the Notebook Dashboard and User Interface Naming a Notebook Adding Text with a Markdown Cell Adding Code and Making Plots with a Code Cell Working with Output Cells Adding an Image with a Markdown Cell Saving the Notebook Closing the Notebook Getting Help Keyboard Shortcuts The Command Palette Using Notebook Extensions Installing Extensions Enabling Extensions Working with Widgets Installing ipywidgets Creating Widgets with Interact Creating Widgets with Interactive Manually Creating Widgets Handling Events Customizing Widgets Embedding Widgets in Other Formats Sharing Notebooks Checking and Running Notebooks with the Kernel Menu Downloading Notebooks Sharing Notebooks via GitHub and Gist Sharing Notebooks via Jupyter Notebook Viewer Sharing Notebooks via Binder Other Sharing Options Trusting Notebooks Turning Notebooks into Slideshows Installing the RISE Extension Creating a Slideshow Using Speaker Notes Summary 6 JUPYTERLAB: YOUR CENTER FOR SCIENCE When to Use JupyterLab Instead of Notebook? Installing JupyterLab The Naive Approach The Modular Approach Building a 3D Astronomical Simulation Using Dedicated Project Folders The JupyterLab Interface The Menu Bar The Left Sidebar Creating a New Notebook Naming the Notebook Using Markdown Cells Adding Code and Making Plots Adding a Console Displaying an Image File Exploring the Simulation Opening Multiple Notebooks Saving the Workspace Clearing the Workspace Closing the Workspace Taking Advantage of the JupyterLab Interface Creating Synchronized Views Copying Cells Between Notebooks Staying Focused by Using Single Document Mode Using the Text Editor Running a Script in a Terminal Running a Script in a Notebook Simultaneously Writing and Documenting Code Using JupyterLab Extensions Installing and Managing Extensions with the Extension Manager Installing and Managing Extensions Using the CLI Installing ipywidgets for JupyterLab Creating Custom Extensions Sharing Summary PART II: A PYTHON PRIMER 7 INTEGERS, FLOATS, AND STRINGS Mathematical Expressions Mathematical Operators The Assignment Operator Augmented Assignment Operators Precedence The math Module Error Messages Data Types Accessing the Data Type Integers Floats Strings Summary 8 VARIABLES Variables Have Identities Assigning Variables Using Expressions Operator Overloading Using Functions Chained Assignment and Internment Using f-Strings Naming Variables Reserved Keywords Variables Are Case Sensitive Best Practices for Naming Variables Managing Dynamic Typing Issues Handling Insignificant Variables Getting User Input Using Comparison Operators Summary 9 THE CONTAINER DATA TYPES Tuples Creating Tuples Converting Other Types to Tuples Working with Tuples Lists Creating Lists Working with Lists Sets Creating Sets Working with Sets Creating Frozensets Dictionaries Creating Dictionaries Combining Two Sequences into a Dictionary Creating Empty Dictionaries and Values Working with Dictionaries Summary 10 FLOW CONTROL The if Statement Working with Code Blocks Using the else and elif Clauses Using Ternary Expressions Using Boolean Operators Loops The while Statement The for Statement Loop Control Statements Replacing Loops with Comprehensions Handling Exceptions Using try and except Forcing Exceptions with the raise Keyword Ignoring Errors Tracing Execution with Logging Summary 11 FUNCTIONS AND MODULES Defining Functions Using Parameters and Arguments Positional and Keyword Arguments Using Default Values Returning Values Naming Functions Built-in Functions Functions and the Flow of Execution Using Namespaces and Scopes Using Global Variables Using a main() Function Advanced Function Topics Recursion Designing Functions Lambda Functions Generators Modules Importing Modules Inspecting Modules Writing Your Own Modules Naming Modules Writing Modules That Work in Stand-Alone Mode Built-in Modules Summary 12 FILES AND FOLDERS Creating a New Spyder Project Working with Directory Paths The Operating System Module Absolute vs. Relative Paths The pathlib Module The Shell Utilities Module Working with Text Files Reading a Text File Closing Files Using the with Statement Writing to a Text File Reading and Writing Text Files Using pathlib Working with Complex Data Pickling Data Shelving Pickled Data Storing Data with JSON Catching Exceptions When Opening Files Other Storage Solutions Summary 13 OBJECT-ORIENTED PROGRAMMING When to Use OOP Creating a New Spyder Project Defining the Frigate Class Defining Instance Methods Instantiating Objects and Calling Instance Methods Defining a Guided-Missile Frigate Class Using Inheritance Instantiating a New Guided-Missile Frigate Object Using the super() Function for Inheritance Objects Within Objects: Defining the Fleet Class Reducing Code Redundancy with Dataclasses Using Decorators Defining the Ship Class Identifying Friend or Foe with Fields and Post-Init Processing Optimizing Dataclasses with __slots__ Making a Class Module Summary 14 DOCUMENTING YOUR WORK Comments Single-Line Comments Multiline Comments Inline Comments Commenting-Out Code Docstrings Documenting Modules Documenting Classes Documenting Functions and Methods Keeping Docstrings Up to Date with doctest Checking Docstrings in the Spyder Code Analysis Pane Summary PART III: THE ANACONDA ECOSYSTEM 15 THE SCIENTIFIC LIBRARIES The SciPy Stack NumPy SciPy SymPy pandas A General Machine Learning Library: scikit-learn The Deep Learning Frameworks TensorFlow Keras PyTorch The Computer Vision Libraries OpenCV scikit-image PIL/Pillow The Natural Language Processing Libraries NLTK spaCy The Helper Libraries Requests Beautiful Soup Regex Dask Summary 16 THE INFOVIS, SCIVIS, AND DASHBOARDING LIBRARIES InfoVis and SciVis Libraries Matplotlib seaborn The pandas Plotting API Altair Bokeh Plotly HoloViews Datashader Mayavi and ParaView Dashboards Dash Streamlit Voilà Panel Choosing a Plotting Library Size of Dataset Types of Plots Format Versatility Maturity Making the Final Choice Summary 17 THE GEOVIS LIBRARIES The Geospatial Libraries GeoPandas Cartopy Geoplot Plotly folium ipyleaflet GeoViews: The HoloViz Approach KeplerGL pydeck Bokeh Choosing a GeoVis Library Summary PART IV: THE ESSENTIAL LIBRARIES 18 NUMPY: NUMERICAL PYTHON Introducing the Array Describing Arrays Using Dimension and Shape Creating Arrays Accessing Array Attributes Indexing and Slicing Arrays Manipulating Arrays Shaping and Transposing Joining Arrays Splitting Arrays Doing Math Using Arrays Vectorization Broadcasting The Matrix Dot Product Incrementing and Decrementing Arrays Using NumPy Functions Reading and Writing Array Data Summary 19 DEMYSTIFYING MATPLOTLIB Anatomy of a Plot The pyplot and Object-Oriented Approaches Using the pyplot Approach Creating and Manipulating Plots with pyplot Methods Working with Subplots Building Multipanel Displays Using GridSpec Using the Object-Oriented Style Creating and Manipulating Plots with the Object-Oriented Style Working with Subplots Building Multipanel Displays Using GridSpec Insetting Plots Plotting in 3D Animating Plots Styling Plots Changing Runtime Configuration Parameters Creating and Using a Style File Applying Style Sheets Summary 20 PANDAS, SEABORN, AND SCIKIT-LEARN Introducing the pandas Series and DataFrame The Series Data Structure The DataFrame Data Structure The Palmer Penguins Project The Project Outline Setting Up the Project Importing Packages and Setting Up the Display Loading the Dataset Displaying the DataFrame and Renaming Columns Checking for Duplicates Handling Missing Values Exploring the Dataset Predicting Penguin Species Using K-Nearest Neighbors Summary 21 MANAGING DATES AND TIMES WITH PYTHON AND PANDAS Python datetime Module Getting the Current Date and Time Assigning Timestamps and Calculating Time Delta Formatting Dates and Times Converting Strings to Dates and Times Plotting with datetime Objects Creating Naive vs. Aware Objects Time Series and Date Functionality with pandas Parsing Time Series Information Creating Date Ranges Creating Periods Creating Time Deltas Shifting Dates with Offsets Indexing and Slicing Time Series Resampling Time Series Summary APPENDIX ANSWERS TO THE “TEST YOUR KNOWLEDGE” CHALLENGES INDEX
Donate to keep this site alive
How to download source code?
1. Go to: https://nostarch.com/
2. Search the book title: Python Tools for Scientists: An Introduction to Using Anaconda, JupyterLab, and Python’s Scientific Libraries
, sometime you may not get the results, please search the main title
3. Click the book title in the search results
3. Download the Source Code.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.