Troubleshooting Unexpected 'False' Output in Pandas String Data Type Check #83
Unanswered
Blignaut24
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Course Details
Course: Complete A.I. Machine Learning and Data Science: Zero to Mastery
Module: Milestone Project 2: Supervised Learning (Time Series Data)
Lesson: Turning Data Into Numbers
Timestamp: 04:07
My error
Hey, I'm currently working with a pandas DataFrame called
df_tmp
and I'm having an issue with one of the columns - "UsageBand". I am trying to check whether this column's datatype is a string using the commandpd.api.types.is_string_dtype(df_tmp["UsageBand"])
. According to my expectations, this command should returnTrue
if "UsageBand" is indeed of string type. However, I'm gettingFalse
as the output, which is causing some confusion. Can you help me understand why this might be happening and how I can resolve it?df_tmp
.pd.api.types.is_string_dtype(df_tmp["UsageBand"])
.True
if "UsageBand" is of string type.False
, causing confusion.I would greatly appreciate the help.
My code
`
Convert string to categories
One way we can turn all of our data into numbers is by converting them into pandas categories.
We can check the difference datatypes compatible with pandas here:
Pandas Data types related functionality
</style>
</div>
False
Error
In tutorial this output above needs to be True - Turning Data Into Numbers (04:07)
`#### Convert string to categoriesOne way we can turn all of our data into numbers is by converting them into pandas categories.
We can check the difference datatypes compatible with pandas here:
[Pandas Data types related functionality](https://pandas.pydata.org/pandas-docs/version/1.4/reference/general_utility_functions.html)
Error
In tutorial this output above needs to be True - Turning Data Into Numbers (04:07)`
What I've tried so far
Beta Was this translation helpful? Give feedback.
All reactions