Quick NumPy question 👀 What will this print? meals = np.array([[1, 2], [3, 4], [5, 6]]) print(len(meals) == meals.size) 🧠 Step-by-step: In this line: meals is a NumPy array that looks like: [[1, 2], [3, 4], [5, 6]] So we have: • 3 rows • 2 columns 🔹 Step 1: len(meals) In NumPy: ➡️ len() returns the number of rows So: len(meals) = 3 🔹 Step 2: meals.size returns the total number of elements in the array 3 × 2 = 6 → meals.size = 6 🔹 Step 3: Comparison: 3 == 6 → False ✅ Final Output: False 💡 Note (important): If it was a 1D array: np.array([1, 2, 3]) Then: len = size = 3 Because it’s a 1D array, len() returns the number of elements (same as size), since there is only one dimension. 📌 Summary: • In 1D arrays: len() == size • In 2D arrays: • len() → number of rows • size → total elements #Python #NumPy #DataScience #CodingTips #LearnPython
NumPy Array Length vs Size Comparison
More Relevant Posts
-
💠 I open every new dataset the same way. Same 6 checks. Every single time. No exceptions. Here’s the exact checklist I use: # 1. What am I working with? print(df.shape) print(df.dtypes) print(df.head()) # 2. What’s missing? print(df.isnull().sum()) print(df.isnull().mean() * 100) # as % # 3. Any duplicates? print(df.duplicated().sum()) # 4. Do the numbers make sense? print(df.describe()) # 5. Are text columns consistent? for col in df.select_dtypes(include="object").columns: print(df[col].value_counts(dropna=False).head(10)) # 6. How unique is each column? print(df.nunique()) This whole thing takes 3 minutes to run. But it tells me six things before I touch a single value: → How big the dataset is → Which columns have missing data and how much → Whether any rows are duplicated → Whether numbers look suspicious → Whether text has case or spelling problems → Whether any column is nearly constant (useless for modelling) I used to skip these steps and jump straight to building. Then I’d spend days fixing model results that were wrong because of data I never looked at. Now I look first. Always. Because you can’t clean what you haven’t seen. Save this checklist. Run it on your next dataset before you do anything else. ❓ Which of these 6 checks do you already run? Which ones do you skip? #DataScience #Python #Pandas
To view or add a comment, sign in
-
If you are doing data analysis in Python, pandas pivot tables are one of the most powerful tools you can master. They let you go from raw, messy data to a clean, structured summary in just a few lines of code —grouping by multiple dimensions, applying aggregation functions, handling missing values, and adding totals automatically. Once you understand pivot tables, your data analysis workflow becomes significantly faster and more insightful. If you are still doing everything manually with loops and conditional logic, it is time to learn pivot tables. Read the full post here: https://lnkd.in/eCaBFSB5 #Python #Pandas #DataScience #DataAnalysis #DataEngineering #Analytics
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗴𝗿𝗮𝗽𝗵 𝗹𝗼𝗼𝗸𝗲𝗱 𝘀𝗶𝗺𝗽𝗹𝗲. 𝗧𝗵𝗲 𝗰𝗼𝗱𝗲 𝘁𝗵𝗮𝘁 𝗯𝘂𝗶𝗹𝘁 𝗶𝘁 𝗱𝗶𝗱𝗻'𝘁. Day 22 of #1000DaysOfLearning 🗓️ Today I plotted my first graph in matplotlib — a 𝘀𝗰𝗮𝘁𝘁𝗲𝗿 𝗽𝗹𝗼𝘁. 📊 What I worked through: → plt.scatter() vs plt.plot() — and what each communicates → Controlling 𝗺𝗮𝗿𝗸𝗲𝗿 𝘀𝗶𝘇𝗲, 𝗰𝗼𝗹𝗼𝗿, 𝗹𝗮𝗯𝗲𝗹𝘀, 𝘁𝗶𝘁𝗹𝗲𝘀, 𝗮𝗻𝗱 𝗹𝗲𝗴𝗲𝗻𝗱𝘀 → Grouping data points using slicing and color lists The code gets long for what looks like a simple output. But 𝘁𝗵𝗮𝘁 𝗹𝗲𝗻𝗴𝘁𝗵 𝗶𝘀 𝘁𝗵𝗲 𝗰𝗼𝗻𝘁𝗿𝗼𝗹 — every label, every color, every legend entry is a deliberate line. Matplotlib assumes nothing. 🎯 Also noticed that 𝘇𝗶𝗽 𝗮𝗻𝗱 𝘁𝘂𝗽𝗹𝗲 𝘂𝗻𝗽𝗮𝗰𝗸𝗶𝗻𝗴, which felt less useful in regular Python, come up naturally when working with coordinate data. Made more sense here than any time I saw them before. 💡 #Python #DataScience #Matplotlib #DataVisualization #LearningInPublic
To view or add a comment, sign in
-
-
🚀 𝗗𝗮𝘆 𝟯 : 𝗧𝗼𝗱𝗮𝘆 𝗜 𝗲𝘅𝗽𝗹𝗼𝗿𝗲𝗱 𝘀𝗼𝗺𝗲 𝗯𝗮𝘀𝗶𝗰 𝗯𝘂𝘁 𝘃𝗲𝗿𝘆 𝗶𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗶𝗻 𝗣𝗮𝗻𝗱𝗮𝘀 𝗳𝗼𝗿 𝗱𝗮𝘁𝗮 𝘂𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 📊 🔍 1. head() Shows the first 5 rows of the dataset df.head() 🔍 2. tail() Shows the last 5 rows df.tail() 📏 3. shape Returns number of rows and columns df.shape ℹ️ 4. info() Provides summary of dataset (data types, null values) df.info() 📊 5. describe() Gives statistical summary (mean, min, max, etc.) df.describe() 📌 6. columns Shows all column names df.columns 💡 Key Learning: Understanding your dataset is the first step before doing any analysis. #Day3 #Pandas #Python #DataAnalytics #LearningJourney #DataExploration
To view or add a comment, sign in
-
Right now, I’m keeping my stack simple and focused: Python This is where everything starts for me. Most of what I build runs on it. Pandas My go-to for working with data. Cleaning, filtering, analyzing — all in one place. NumPy Helps me understand what’s happening under the hood with arrays and calculations. Matplotlib Still learning, but using it to visualize data and actually “see” patterns. Alongside this, I’ve started focusing more on math for ML. Taking it slow, trying to really understand concepts instead of rushing through. Feels like going back to basics, but in a good way. If you’re on a similar path, what are you focusing on right now?
To view or add a comment, sign in
-
-
🚀 Simplifying Trees in DSA! 🌳💻 While Arrays and Linked Lists are great linear structures, hierarchical data requires a Non-Linear approach—like Trees! To make revising easier, I created this visual cheat sheet. Just like a real-world tree has a Root and Leaves, a Tree data structure starts at the Root Node and branches out to Intermediate and Leaf Nodes. Here is what I have visually summarized in these notes: ✅ The core difference between Linear and Non-Linear structures ✅ 7 Types of Trees (including BST, Strict, Complete, and Skew Trees) ✅ Array Representation vs. Logical View ✅ Tree Traversal logic (Pre-order, In-order, Post-order) complete with Python code! 🐍 Visualizing the flow from the root down to the leaf nodes is a game-changer for understanding algorithms. Take a look and let me know in the comments—what is your favorite data structure to work with? 👇 #DSA #DataStructures #Algorithms #Python #CodingJourney #TechNotes #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
Advanced pandas tricks that make you 10x faster at data wrangling. Most people learn pandas basics and stop. This free notebook covers what comes after. → MultiIndex: hierarchical indexing for complex datasets → .pipe() — chain custom functions into your workflow → Method chaining: write entire analyses in one readable block → Memory optimization: reduce DataFrame memory by 70%+ → Vectorized operations: why your for loop is 100x slower → Performance patterns the documentation buries If your pandas code has more than 2 for loops, this notebook will change how you write it. Every trick has before/after benchmarks. See the speed difference yourself. Free: https://lnkd.in/g7HsJfGy Day 3/7. #Python #Pandas #DataAnalyst #DataScience #DataWrangling #Performance #FreeResources #DataAnalytics
To view or add a comment, sign in
-
Seaborn vs Matplotlib — what’s the difference? While learning data visualization, I explored both libraries and here’s my simple understanding - 📊 Matplotlib 🔹 Basic and highly customizable 🔹 More control over plots 🔹 Requires more code 📊 Seaborn 🔹 Built on top of Matplotlib 🔹 More visually appealing 🔹 Easier to use for statistical plots 💡 My takeaway: Matplotlib gives control, Seaborn gives simplicity and better visuals. Using both together is the best approach. Which one do you prefer? #Python #Seaborn #Matplotlib #DataVisualization #LearningInPublic
To view or add a comment, sign in
-
Boxplots are a great data visualisation and are commonly used during the EDA phase of a project. They give a clean statistical summary of a distribution and make it easy to compare groups, spot potential outliers, and get a feel for spread without much effort. The problem is that boxplots can also hide a lot of what actually matters. A boxplot won’t show you much about clustering, gaps, or how many data points sit behind each group. In my latest article, I walk through a simple fix in Python using seaborn and matplotlib: combining a boxplot with the raw data points. That way, you still get the familiar summary statistics, but you also get to see the observations behind them. It’s a small change, but it's one that can make boxplots much more informative. Link in the comments below 👇 #Python #DataVisualization #Seaborn #Matplotlib
To view or add a comment, sign in
-
-
In a world full of flashy visualization tools, Matplotlib continues to stand its ground - and for good reason. What makes it special isn’t just its longevity, but its balance of simplicity and power. You can start with a few lines of code to create basic plots, yet dive deep into customization when you need publication-quality visuals. To keep things practical, I’ve put together a simple 2-page starter template (attached) - with ready-to-use code and a clean structure that anyone can build on. Whether you're exploring data, building dashboards, or fine-tuning scientific plots, Matplotlib adapts to your needs without forcing complexity upfront. Sometimes, the most powerful tools are the ones that stay simple. #DataScience #Python #Matplotlib #DataVisualization #Learning
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development