Your series contains other pd.Series
objects. This is bad practice. In general, you should ensure your series is of a fixed type to enable you to perform manipulations without having to check for type
explicitly.
Your error is due to pd.Series
objects not being hashable. One workaround is to use a function to convert pd.Series
objects to a hashable type such as tuple
:
s = pd.Series(['one string', 'another string', pd.Series([1, 2, 3])]) def converter(x): if isinstance(x, pd.Series): return tuple(x.values) else: return x res = s.apply(converter).unique() print(res) ['one string' 'another string' (1, 2, 3)]
Related Posts:
- Renaming column names in Pandas
- How to deal with SettingWithCopyWarning in Pandas
- How to deal with SettingWithCopyWarning in Pandas
- How to iterate over rows in a DataFrame in Pandas
- Writing a pandas DataFrame to CSV file
- Adding new column to existing DataFrame in Python pandas
- Modifing data while using iterrows() does not work
- ImportError: No module named pandas
- How to change the order of DataFrame columns?
- How to change the order of DataFrame columns?
- ImportError: No module named pandas. Pandas installed pip
- What does `ValueError: cannot reindex from a duplicate axis` mean?
- How can I use the apply() function for a single column?
- Convenient way to deal with ValueError: cannot reindex from a duplicate axis
- How to fix IndexError: invalid index to scalar variable
- “Series objects are mutable and cannot be hashed” error
- Merging dataframes on index with pandas
- Create a Pandas Dataframe by appending one row at a time
- Convert Python dict into a dataframe
- re.sub erroring with “Expected string or bytes-like object”
- How do I select rows from a DataFrame based on column values?
- How do I select rows from a DataFrame based on column values?
- Pandas group-by and sum
- How do I get the row count of a Pandas DataFrame?
- Python pandas groupby aggregate on multiple columns, then pivot
- Convert pandas dataframe to NumPy array
- Error:cannot convert float NaN to integer in pandas
- Replacing column values in a pandas DataFrame
- How do I get the row count of a Pandas DataFrame?
- Python Pandas – Missing required dependencies [‘numpy’] 1
- Pandas “Can only compare identically-labeled DataFrame objects” error
- Pandas: ValueError: cannot convert float NaN to integer
- Get list from pandas dataframe column or row?
- pandas DataFrame “no numeric data to plot” error
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- ‘DataFrame’ object has no attribute ‘sort’
- ‘DataFrame’ object has no attribute ‘sort’
- TypeError: cannot unpack non-iterable int objec
- Pandas DataFrame column to list
- Rename Pandas DataFrame Index
- pandas: filter rows of DataFrame with operator chaining
- Convert DataFrame column type from string to datetime, dd/mm/yyyy format
- Pandas how to use pd.cut()
- How to Read .txt in Pandas
- Get a list from Pandas DataFrame column headers
- How to check whether a pandas DataFrame is empty?
- Convert columns to string in Pandas
- Python TypeError: cannot convert the series to
when trying to do math on dataframe - Shuffle DataFrame rows
- How to take column-slices of dataframe in pandas
- How to load a tsv file into a Pandas DataFrame?
- How to iterate over columns of pandas dataframe to run regression
- JSON to pandas DataFrame
- Converting between datetime and Pandas Timestamp objects
- Creating a Pandas DataFrame from a Numpy array: How do I specify the index column and column headers?
- Convert pandas data frame to series
- Modify the legend of pandas bar plot
- Get first row value of a given column
- Selecting/excluding sets of columns in pandas
- How to add title to seaborn boxplot
- How to filter Pandas dataframe using ‘in’ and ‘not in’ like in SQL
- Deleting DataFrame row in Pandas based on column value
- Map to List error: Series object not callable
- Pandas long to wide reshape, by two variables
- SettingWithCopyWarning even when using .loc[row_indexer,col_indexer] = value
- Pandas DataFrame: replace all values in a column, based on condition
- How to convert string to datetime format in pandas python?
- OSError: Initializing from file failed on csv in Pandas
- Data type conversion error: ValueError: Cannot convert non-finite values (NA or inf) to integer
- Pandas – How to flatten a hierarchical index in columns
- Pandas OR statement ending in series contains
- AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas
- Python Pandas ValueError Arrays Must be All Same Length
- Plot correlation matrix using pandas
- Plotting multiple lines, in different colors, with pandas dataframe
- Groupby value counts on the dataframe pandas
- TypeError: cannot concatenate a non-NDFrame object
- Rename specific column(s) in pandas
- Pandas – Drop function error (label not contained in axis)
- Pandas index column title or name
- ImportError: No module named ‘xlrd’
- Building multi-regression model throws error: `Pandas data cast to numpy dtype of object. Check input data with np.asarray(data).`
- Moving Average Pandas
- Importing Pandas gives error AttributeError: module ‘pandas’ has no attribute ‘core’ in iPython Notebook
- python pandas remove duplicate columns
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- Concat DataFrame Reindexing only valid with uniquely valued Index objects
- How to convert index of a pandas dataframe into a column
- Replacing Pandas or Numpy Nan with a None to use with MysqlDB
- pandas replace multiple values one column
- Convert floats to ints in Pandas?
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- Pandas unstack problems: ValueError: Index contains duplicate entries, cannot reshape
- Python: Convert timedelta to int in a dataframe
- Calculate weighted average using a pandas/dataframe
- Got continuous is not supported error in RandomForestRegressor
- Extract first and last row of a dataframe in pandas
- ValueError: multiclass format is not supported
- ValueError: Must pass DataFrame with boolean values only
- Extracting specific selected columns to new DataFrame as a copy