#052 - Python Dictionaries for Engineers
Building Robust Data Structures for Engineering Applications: Dictionaries and DataFrames
A Quick Update
I really appreciate the feedback and the conversations that have been sparked from the Flocode Project. Thanks to you all.
I've been getting requests about a status update on the Flocode curriculum. I will provide a more detailed update soon. It's been my own journey across Middle Earth - I have spoken to many engineers who have helped to shape my perspective on what they need to know and learn regarding Python, so things have become a little clearer thanks to this feedback.
The Flocode Project aims to empower engineers with practical Python skills. This article explores two fundamental data structures in Python: dictionaries and dataframes, essential tools for organizing and processing engineering data.
Be good everybody, and I'll see you in the next one.
James ๐
Python Dictionaries for Engineers
In Python, dictionaries are one of the most powerful and versatile data structures. They are collections of key-value pairs, much like a real-world dictionary where you look up a word (key) to find its meaning (value). For engineers, dictionaries can organize our data in a clear and structured way that can be accessed, manipulated, and processed efficiently.
Why Dictionaries?
We often handle large and complex datasets. We might need to store attributes of structural members, characteristics of hydraulic systems, parameters of equipment, or sets of sensor readings. Dictionaries allow us to group these related data points in a single structure, making them easier to access and manipulate. By using dictionaries, we can:
Map complex relationships between data points in an intuitive way.
Access data by key without needing to search through arrays or lists.
Easily update, add, or remove key-value pairs as our datasets change or evolve.
For instance, if we're working with material attributes for a structural analysis, we could store properties like Young's modulus, density, and tensile strength in a dictionary for each material:
# Dictionary storing material attributes
steel = {
'Youngs Modulus': 210e9, # Pa
'Density': 7850, # kg/m^3
'Tensile Strength': 400e6 # Pa
}
In this way, dictionaries act as simple databases, offering a clear way to organize properties associated with specific elements.
If you want to play with this code, see here for GitHub Gist.
Keep reading with a 7-day free trial
Subscribe to Flocode: Engineering Insights ๐ to keep reading this post and get 7 days of free access to the full post archives.