Last answered:

27 Feb 2023

Posted on:

03 Nov 2022


location_data becomes DataFrame type

After I import the csv file location.csv downloaded with Pandas read_csv method, it returns a DataFrame other than Series like the video showed. Therefore when I try to call .unique method, it threw an error saying this method does not work for DataFrame.

3 answers ( 0 marked as helpful)
Posted on:

10 Nov 2022


Hi June!
Thanks for reaching out!

Could you please support your question with a screenshot containing the entire code you’ve executed? This can help us assist you better. Thank you.

Looking forward to your answer.

Posted on:

09 Jan 2023


PFA screenshot, Even when I am getting it as DataFrame instead of Series


Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

27 Feb 2023


So it looks like what is happening is when you remove the "squeeze = True" to get around the warning, it turns the imported file from a Series to a dataframe. Here is the correct syntax to get around the warning and maintain the imported file as a Series.

# squeeze is being depreciated; if you remove squeeze, it will turn into a data frame (and not a Series)
# Which will cause more issues in the next cells
# data = pd.read_csv('Location.csv', squeeze = True)

# This does not work either, it turns into a dataframe
# data = pd.read_csv('Location.csv')
# data.squeeze("columns")

# Correct syntax is:
data = pd.read_csv('Location.csv').squeeze("columns")


# Store a copy of this object’s indices and data.
location_data = data.copy()


# Display the first five rows

Submit an answer