Issue
subset = example.iloc[0:100,0]
print(subset)
0 0.467976
1 -0.358893
2 -0.501840
3 0.204886
4 0.354628
...
95 1.106521
96 -0.540543
97 -0.101980
98 0.632107
99 1.009779
Name: one, Length: 100, dtype: float64
I Wanna convert it into something look like [0.467976300189, -0.358893469543, -0.50184039929, 0.20488621220199998, ...].
If I use
subset.values.tolist()
It shows something like
[[0.467976300189],
[-0.358893469543],
[-0.50184039929],
[0.204886212202],
[0.354627914484],
[1.81748001608],
[-0.776764319165],
[-0.913134961617],
[0.358479538224],
[-1.74087710829],
[0.24056373835],
[0.764018252198],
[0.571034923177],
[2.31765810894],
[1.54777073472],
[-1.31060811665],
[-0.0884964396951],
[-0.0186628260149],
[-0.0701272145463],
[-0.194677940725],
[-0.248617847177],
[-1.09154895394],
[0.641404300148],
[1.21640846838]
which is a little bit different from what I want.
Any idea?
If I use ```python subset_list = subset.column.to_list()
```python
AttributeError Traceback (most recent call last)
<ipython-input-102-effce8140c99> in <module>
----> 1 subset_list = subset.column.to_list()
~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in __getattr__(self, name)
5463 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5464 return self[name]
-> 5465 return object.__getattribute__(self, name)
5466
5467 def __setattr__(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'column'
Solution
Try using the following to have subset
as the list
subset = example.iloc[0:100,0].to_list()
Answered By - Luke
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.