A column can look exactly right and still refuse to behave. The values read 12, 7, and 9. You ask for their total and get an error, or a sorting order no person would choose. The instinct is to suspect the formula or your own logic. Usually neither is the problem. What you think Python is holding and what Python is actually holding are two different things, and only one of those opinions runs. That disagreement is the root of many failures in tabular work — and it is avoidable, because Python will tell you what it holds if you ask first.
Type is what an operation means
Every value in Python carries a type, and the type decides what operations mean. A whole number is an integer. A number with a fractional part is a float. Quoted text is a string. A date, once parsed, is a date or datetime object. A missing entry is a special marker that must be handled deliberately, because left alone it can spoil arithmetic that touches it.
These are not labels for tidiness. Adding two integers sums them. Adding two strings joins them end to end. Adding an integer to a string stops the program. Dividing two integers produces a float. Comparing values of mixed types can order them in a way no human would pick. The same symbols do different work depending on the types they meet, which is why a result that looks odd should send you to the types first, not to the reasoning. Print the type of the thing. Look at a few actual values. Only then debug the logic — because if the types are wrong, correct logic will still produce a wrong answer, or a plausible one, which is worse.
The misconception underneath is natural: that Python can see that "12" means twelve, and the quotes are just how it was typed into a spreadsheet. Python does not see that. Quoted, it is text that happens to look like a number. Text sorts differently — "10" can come before "9" — text refuses an average, and sometimes text quietly produces an answer that passes a casual glance and fails the decision built on it.
A small table makes the point
Consider a table built in pandas, the library this work is usually done in. Three rows record orders: two from a store called North and one from South, with units of 12, 7, and 9, and prices of 5.0, 5.0, and 6.0. The first thing to take is the table's shape, which reports three rows and three columns. That pair is a vital sign: you should be able to predict it before the cell runs, and if the machine reports something else, the data is not what you thought.
Pull the units column out and convert it to a plain list, and you see the actual values: 12, 7, 9. Their sum is 28. The arithmetic works for one reason only: the units were entered as integers. Build the identical table with the units quoted — "12", "7", "9" — and the display barely changes while the behavior changes completely. The sum stops being arithmetic, because text does not add that way.
Identical display, different type, different behavior. Files arriving from spreadsheets are where this happens most often, since a stray space or a thousands separator can flip an entire column to text without changing how it looks. A column's appearance is a rendering. Its type is a fact.
Tables have an anatomy worth learning early
Below the table sit collections. A list is an ordered row of values, which may mix types. A dictionary pairs keys with values — one record, field by named field. A table, a DataFrame, is a grid of named columns, each a series of values with one type, and rows identified by position or by an index.
That anatomy gives you the questions to ask of any table on arrival. What is its shape? What type does each column carry, and does it match its job? Quantities need to be numeric before they can be summed. Codes are often honestly text. Dates need to be parsed into real date objects before date arithmetic, because text that looks like a date cannot tell you how many days lie between two of them. Ask before filtering or grouping gives a wrong type a chance to travel further.
Three moves that cover most of the ground
First, look at values, not formats: pull a few entries out as plain Python objects and read them as they are. Second, ask each column its type and compare it with the type its job requires — this catches the column that arrived as text and the date that was never parsed. Third, convert deliberately, in code, when a type is wrong: a named, visible step a rerun can repeat, not a silent hope that the library will guess. A guess that works on this file may fail on next month's, and no one will know what changed.
One more distinction: the copy and the original
There is a related trap: when you select part of a table and modify it, you must know whether you changed the original or a separate copy. The safe habit is blunt — make an explicit copy and modify that, and when a warning about chained or ambiguous assignment appears, restructure the code until the intent is unambiguous. Otherwise you risk the classic silent failure: a table supposedly fixed that never was, because the fix landed on a copy that was thrown away.
The discipline underneath all of this is simple. The machine's opinion about your data is the only one that executes. Make it match yours — in the open, before you build anything that depends on it.
Experience it, don’t just read about it
What Python actually holds — type, not appearance, as the fact that decides behavior is Concept 2 of Python for Data Science & Machine Learning (Course No. 214), from Cognosco Learning, a learning company powered by AI. The course builds the wider practice beyond this distinction — Loading Tabular Data — Reading Files Without Lying to Yourself, Cleaning in Code — Missing, Duplicated, and Mistyped Values, and Grouping and Aggregation — Summaries That Respect the Grain — each worked through with an Agentic Socratic AI coach, one learner at a time. Try a Free Preview at cognoscolearning.com.
Navigate your own course.
© 2026 Cognosco Learning. All rights reserved.