You are using tolist incorrectly. You want: .values followed by tolist()

  type   tsneX      tsneY  
0  A      53.828863  20.740931  
1  B      57.816909  18.478468  
2  A      55.913429  22.948167  
3  C      56.603005  15.738954 

For the above dataframe, to get your X and Y values as a list you can do:

tsneY_data = df['tsneY'].values.tolist()
>> [20.740931, 18.478468, 22.948167, 15.7389541]

tsneX_data = df['tsneX'].values.tolist()
>> [53.828863, 57.816909, 55.913429, 56.603005]

As you have tried to set this to the column of a new dataframe, you can do:

new_data = pd.DataFrame()
new_data['tsneY'] = df['tsneY'].values.tolist()

> new_data
       tsneY
0  20.740931
1  18.478468
2  22.948167
3  15.738954
Answer from Chuck on Stack Overflow
Discussions

AttributeError: 'Index' object has no attribute 'to_list' in function decision_plot
When trying to call the function "shap.decision_plot", I get the aforementioned error. It seems that it is an issue related to the use of "to_list()". explainer = shap.TreeExpla... More on github.com
🌐 github.com
7
December 12, 2019
BUG: AttributeError: 'StringArray' object has no attribute 'tolist'
I have checked that this issue has not already been reported. I have confirmed this bug exists on the latest version of pandas. (optional) I have confirmed this bug exists on the master branch of p... More on github.com
🌐 github.com
5
April 24, 2021
python - sklearn package with AttributeError: 'MissingValues' object has no attribute 'to_list' - Data Science Stack Exchange
I am currently trying to reproduce this tutorial on building a CNN based time series classifier for human activity recognition. My setup is: Windows 10, Pycharm IDE with a new project for this tut... More on datascience.stackexchange.com
🌐 datascience.stackexchange.com
Test_race_count ERROR AttributeError: 'DataFrame' object has no attribute 'tolist'
Tell us what’s happening: I receive the following error message: ERROR: test_race_count (test_module.DemographicAnalyzerTestCase) Traceback (most recent call last): File “PycharmProjects\Data Analysis Projects\test_m… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
June 1, 2021
🌐
GitHub
github.com › facebook › prophet › issues › 2229
'list' object has no attribute 'tolist' · Issue #2229 · facebook/prophet
July 13, 2022 - While fit my data by updating fitted model, the following error appears Traceback (most recent call last): File "/dockerdata/jiangszhang/anaconda3/envs/abnormal_detection/lib/python3.7/site-packages/joblib/externals/loky/process_executor...
Author   RiskySignal
🌐
GitHub
github.com › slundberg › shap › issues › 944
AttributeError: 'Index' object has no attribute 'to_list' in function decision_plot · Issue #944 · shap/shap
December 12, 2019 - ~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\plots\decision.py in decision_plot(base_value, shap_values, features, feature_names, feature_order, feature_display_range, highlight, link, plot_color, axis_color, y_demarc_color, alpha, color_bar, auto_size_plot, title, xlim, show, return_objects, ignore_warnings, matplotlib) 323 elif str(type(features)) == "<class 'pandas.core.series.Series'>": 324 if feature_names is None: --> 325 feature_names = features.index.to_list() 326 features = features.values 327 elif isinstance(features, list): AttributeError: 'Index' object has no attribute 'to_list' Any help would be really appreciated.
Author   davidgar
🌐
GitHub
github.com › pandas-dev › pandas › issues › 41134
BUG: AttributeError: 'StringArray' object has no attribute 'tolist' · Issue #41134 · pandas-dev/pandas
April 24, 2021 - import pandas as pd import numpy as np lzt = ["a","b","c"] arr = np.array(lzt) df = pd.DataFrame(arr).astype('string') srs = df[0] u = srs.unique() type(u) <class 'pandas.core.arrays.string_.StringArray'> u.dtype == 'string' True u.tolist() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'StringArray' object has no attribute 'tolist' So I tried changing my code to use list(srs.unique()), but then all of my numeric dtypes become unserializable for JSON.
Author   aiqc
🌐
Data Science Learner
datasciencelearner.com › attributeerror-dataframe-object-has-no-attribute-tolist-solved
AttributeError: dataframe object has no attribute tolist ( Solved )
October 2, 2023 - The main or root cause for this error is that you are not using the tolist() function in a proper way. The tolist() function allows you to convert pandas dataframe columns or series to a list.
🌐
Stack Exchange
datascience.stackexchange.com › questions › 90769 › sklearn-package-with-attributeerror-missingvalues-object-has-no-attribute-to
python - sklearn package with AttributeError: 'MissingValues' object has no attribute 'to_list' - Data Science Stack Exchange
Traceback (most recent call last): File "C:/Users/bobin/PycharmProjects/Mussel/cnn_musseltest.py", line 226, in <module> df[LABEL] = le.fit_transform(df["activity"].values.ravel()) File "C:\Users\bobin\PycharmProjects\Mussel\venv\lib\site-packages\sklearn\preprocessing\_label.py", line 117, in fit_transform self.classes_, y = _unique(y, return_inverse=True) File "C:\Users\bobin\PycharmProjects\Mussel\venv\lib\site-packages\sklearn\utils\_encode.py", line 31, in _unique return _unique_python(values, return_inverse=return_inverse) File "C:\Users\bobin\PycharmProjects\Mussel\venv\lib\site-packages\sklearn\utils\_encode.py", line 133, in _unique_python uniques.extend(missing_values.to_list()) AttributeError: 'MissingValues' object has no attribute 'to_list'
Find elsewhere
🌐
GitHub
github.com › asreview › asreview › discussions › 1293
AttributeError: 'Series' object has no attribute 'to_list' · asreview/asreview · Discussion #1293
When I run the AsreviewLab in Oracle mode, I upload the data and selected the relevant and irrelavent data, I selected the model as: Naive Bayes + TF-IDF + Maximum + Dynamic resampling, but it showed "AttributeError: 'Series' object has no attribute 'to_list' ".
Author   asreview
🌐
GitHub
github.com › deepchem › deepchem › issues › 1607
Error when loading DataSet: AttributeError: 'DataFrame' object has no attribute 'tolist' · Issue #1607 · deepchem/deepchem
May 27, 2019 - Problem Description: When I try to load a csv file, following the instructions in the Dataset Creation tutorial (https://deepchem.io/docs/notebooks/dataset_preparation.html), I get the error: AttributeError: 'DataFrame' object has no attribute 'tolist' (Full error log below).
Published   May 27, 2019
Author   sskaye
🌐
GitHub
github.com › d-chambers › Detex › issues › 26
Report 'list' object has no attribute 'tolist' error and failed to write ss_info to SubSpace.db · Issue #26 · d-chambers/Detex
January 3, 2016 - When I run ss.detex with after ss.SVD(threshold =0.15), it failed to write the ss_info to the SubSpace.db and report error: 'list' object has no attribute 'tolist'. I check the code and it seems that the self.histSubSpace[sta][skey] will return a list not an array.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.tolist.html
pandas.Series.tolist — pandas 2.1.4 documentation
Series.tolist()[source]# Return a list of the values. These are each a scalar type, which is a Python scalar (for str, int, float) or a pandas scalar (for Timestamp/Timedelta/Interval/Period) Returns: list · See also · numpy.ndarray.tolist · Return the array as an a.ndim-levels deep nested list of Python scalars.
🌐
GitHub
github.com › mymarilyn › clickhouse-driver › issues › 218
BUG: AttributeError: 'list' object has no attribute 'tolist' when insert_dataframe with use_numpy on · Issue #218 · mymarilyn/clickhouse-driver
May 14, 2021 - Describe the bug get a dataframe by query_dataframe() then insert it by insert_dataframe(), an error occurs. To Reproduce test.a has a column of Array(String) df = client.query_dataframe("SELECT * FROM test.a LIMIT 10;") client.insert_da...
Published   May 14, 2021
Author   panwenbin
🌐
Dataquest Community
community.dataquest.io › q&a › dq courses
Matplotlib attribute error; 'list' object has no attribute 'tolist' - DQ Courses - Dataquest Community
May 3, 2022 - Screen Link: My Code: sib_dict = {0: 608, 1: 209, 2: 28, 4: 18, 3: 16, 8: 7, 5: 5} import matplotlib.pyplot as plt lists = sorted(sib_dict.items()) # sorted by key, return a list of tuples x, y = zip(*lists) # unpack a list of pairs into two tuples plt.plot(x, y) plt.show() What I expected ...
🌐
Reddit
reddit.com › r/learnpython › dict to data frame with pandas ('list' object has no attribute 'values)
r/learnpython on Reddit: dict to data frame with pandas ('list' object has no attribute 'values)
March 4, 2021 -

Hey guys, I am learning how to convert the dictionary to data frame. I have a nested dictionary called user_dict like this:

File of dictionary in pickle format

[{'1000003': {'car': 0.0,    'car_passenger': 0.0,    'pt': 0.0,    'walk': 0.0,    'bike': 0.0}},  {'1000007': {'car': 0.0,    'car_passenger': 0.0,    'pt': 856.0786277323101,    'walk': 2546.869189662443,    'bike': 0.0}},  
{'1000008': {'car': 0.0,    'car_passenger': 34189.569164682835,    'pt': 0.0,    'walk': 0.0,    'bike': 0.0}},  
{'1000009': {'car': 0.0,    'car_passenger': 0.0,    'pt': 0.0,    'walk': 0.0,    'bike': 9847.472668350396}}]

I want to convert the dict to data frame like this:

           car    car_passenger    pt    walk    bike
1000003    0.0    0.0              0.0   0.0     0.0
1000007    0.0    0.0              856.078 2546.869 0.0
1000008    0.0    34189.569        0.0   0.0     0.0
1000009    0.0    0.0              0.0   0.0     9847.472

I converted it through from_dict:

df =pd.DataFrame.from_dict(user_dict,orient='index')
df

But I got an error as this:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-44-2ef0fc236180> in <module>
----> 1 df =pd.DataFrame.from_dict(user_dict,orient='index')
      2 df

/Library/Python/3.7/site-packages/pandas/core/frame.py in from_dict(cls, data, orient, dtype, columns)
   1361             if len(data) > 0:
   1362                 # TODO speed up Series case
-> 1363                 if isinstance(list(data.values())[0], (Series, dict)):
   1364                     data = _from_nested_dict(data)
   1365                 else:

AttributeError: 'list' object has no attribute 'values'

I do not know how to fix it. Can anyone help me or explain me how to fix it?

Any help is appreciated.