ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | FAIL | download_stamp > now() - 6 MONTH | 10.3 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://python-forum.io/thread-35162.html |
| Last Crawled | 2025-06-01 13:33:06 (10 months ago) |
| First Indexed | 2021-10-05 17:56:07 (4 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Removing nan values from a dict |
| Meta Description | The official dedicated python forum, I have this dict: Output:Please how can I remove the nan values? I have used my_dict.pop(nan) but it doesn't work since nan is not a string |
| Meta Canonical | null |
| Boilerpipe Text | >>> lst = [ 438.4 , 439.18 , 439.9 , 440.21999999999997 , 440.38 , 441.08000000000004 , nan, nan, nan, nan] Traceback (most recent call last): File "<interactive input>" , line 1 , in <module> NameError: name 'nan' is not defined >>> lst = [ 438.4 , 439.18 , 439.9 , 440.21999999999997 , 440.38 , 441.08000000000004 , nan, nan, nan, nan] >>> [x for x in lst if ~np.isnan(x)] [ 438.4 , 439.18 , 439.9 , 440.21999999999997 , 440.38 , 441.08000000000004 ] |
| Markdown | [](https://python-forum.io/index.php)
[](https://python-forum.io/index.php)
- [View Active Threads](https://python-forum.io/activethreads.php)
- [View Today's Posts](https://python-forum.io/search.php?action=getdaily)
- [Home](https://python-forum.io/index.php)
- [Forums]()
- [View New Posts](https://python-forum.io/search.php?action=getnew)
- [View Today's Posts](https://python-forum.io/search.php?action=getdaily)
- [My Discussions](https://python-forum.io/search.php?action=do_search&author=&matchusername=1&showresults=threads&postthread=1)
- [Unanswered Posts](https://python-forum.io/search.php?action=unanswered)
- [Unread Posts](https://python-forum.io/search.php?action=unreads)
- [Active Threads](https://python-forum.io/activethreads.php?days=1&hours=0&mins=0&date=Now&order=descending&sort=num_posts&go=Go)
- [Mark all forums read](https://python-forum.io/misc.php?action=markread&my_post_key=ba4b0f4a50d4f57dee24c0cb4fa97aa2)
- [Staff List](https://python-forum.io/showteam.php)
- [Member List](https://python-forum.io/memberlist.php)
- [Help](https://python-forum.io/misc.php?action=help)
- [Calendar](https://python-forum.io/calendar.php)
- [Search](https://python-forum.io/search.php)
- [Statistics](https://python-forum.io/stats.php)
- [Interpreter](https://python-forum.io/misc.php?page=interpreter)
- [IRC](https://python-forum.io/misc.php?page=chat)
##### Removing nan values from a dict
- [Python Forum](https://python-forum.io/index.php)
- [Python Coding](https://python-forum.io/forum-7.html)
- [General Coding Help](https://python-forum.io/forum-8-page-237.html)
**Thread Rating:**
- 0 Vote(s) - 0 Average
- [1](https://python-forum.io/ratethread.php?tid=35162&rating=1&my_post_key=ba4b0f4a50d4f57dee24c0cb4fa97aa2)
- [2](https://python-forum.io/ratethread.php?tid=35162&rating=2&my_post_key=ba4b0f4a50d4f57dee24c0cb4fa97aa2)
- [3](https://python-forum.io/ratethread.php?tid=35162&rating=3&my_post_key=ba4b0f4a50d4f57dee24c0cb4fa97aa2)
- [4](https://python-forum.io/ratethread.php?tid=35162&rating=4&my_post_key=ba4b0f4a50d4f57dee24c0cb4fa97aa2)
- [5](https://python-forum.io/ratethread.php?tid=35162&rating=5&my_post_key=ba4b0f4a50d4f57dee24c0cb4fa97aa2)
| | |
|---|---|
| **[Thread Modes]()** **Removing nan values from a dict** | |
| | |
| 1 | `my_dict.pop(nan)` |
| | |
| 12345678 | `nan``=` `0` `mylist``=` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08000000000004``, nan, nan, nan, nan]` `for` `i``in` `range``(``len``(mylist)):` ` ``if` `i >``=` `6``:` ` ``mylist.pop()` `print``(mylist)` |
| | |
| 123456 | `>>> l` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08``, nan, nan, nan, nan]` `>>>``import` `math` `>>> newlist``=` `[x``for` `x``in` `l``if` `not` `math.isnan(x)]` `>>> newlist` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08``]` |
| | |
| 123456789101112 | `# Give error` `>>> lst``=` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08000000000004``, nan, nan, nan, nan]` `Traceback (most recent call last):` ` ``File` `"<interactive input>"``, line``1``,``in` `<module>` `NameError: name``'nan'` `is` `not` `defined` `>>>``import` `numpy as np` `>>>``from` `numpy``import` `nan``# Fix error` `>>>` `>>> lst``=` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08000000000004``, nan, nan, nan, nan]` `>>> [x``for` `x``in` `lst``if` `~np.isnan(x)]` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08000000000004``]` |
| | |
| 1234567 | `import` `numpy as np` `notadict``=` `np.array([``438.4``,``439.18``,``439.9``, np.nan, np.nan])` `print``(notadict[(~np.isnan(notadict))], notadict)` `print``(np.delete(notadict, np.isnan(notadict)), notadict)` `print``(np.nan_to_num(notadict, nan``=``0.0``), notadict)` `print``(np.nan_to_num(notadict, copy``=``False``, nan``=``0.0``), notadict)` |
| | |
| 12345678 | `nan``=` `0` `mylist``=` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08000000000004``, nan, nan, nan, nan]` `for` `i``in` `range``(``len``(mylist)):` ` ``if` `i >``=` `6``:` ` ``mylist.pop()` `print``(mylist)` |
| | |
| 1 | `my_dict.pop(nan)` |
| | |
| 12345678 | `nan``=` `0` `mylist``=` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08000000000004``, nan, nan, nan, nan]` `for` `i``in` `range``(``len``(mylist)):` ` ``if` `i >``=` `6``:` ` ``mylist.pop()` `print``(mylist)` |
| | |
| 12345678910 | `#! /usr/bin/env python3` `nan``=` `0` `mylist``=` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08000000000004``, nan, nan, nan, nan]` `for` `i``in` `range``(``len``(mylist)):` ` ``if` `0` `in` `mylist:` ` ``mylist.pop()` `print``(mylist)` |
| | |
| 123456 | `>>> l` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08``, nan, nan, nan, nan]` `>>>``import` `math` `>>> newlist``=` `[x``for` `x``in` `l``if` `not` `math.isnan(x)]` `>>> newlist` `[``438.4``,``439.18``,``439.9``,``440.21999999999997``,``440.38``,``441.08``]` |
| | | | | | |
|---|---|---|---|---|---|
| **Possibly Related Threads…** | | | | | |
| **Thread** | **Author** | **Replies** | **Views** | **Last Post** | |
| | [dict class override: how access parent values?](https://python-forum.io/thread-36573.html) | [Andrey](https://python-forum.io/user-32920.html) | [1](https://python-forum.io/misc.php?action=whoposted&tid=36573) | 2,698 | Mar-06-2022, 10:49 PM [Last Post](https://python-forum.io/thread-36573-lastpost.html): [deanhystad](https://python-forum.io/user-23001.html) |
| | [Trouble with converting list , dict to int values\!](https://python-forum.io/thread-29457.html) | [faryad13](https://python-forum.io/user-27243.html) | [7](https://python-forum.io/misc.php?action=whoposted&tid=29457) | 5,455 | Sep-04-2020, 06:25 AM [Last Post](https://python-forum.io/thread-29457-lastpost.html): [faryad13](https://python-forum.io/user-27243.html) |
| | [Sort a dict in dict](https://python-forum.io/thread-25679.html) | [cherry\_cherry](https://python-forum.io/user-24009.html) | [4](https://python-forum.io/misc.php?action=whoposted&tid=25679) | 104,643 | Apr-08-2020, 12:25 PM [Last Post](https://python-forum.io/thread-25679-lastpost.html): [perfringo](https://python-forum.io/user-10222.html) |
| | [How to access specific values from a dict?](https://python-forum.io/thread-24238.html) | [t4keheart](https://python-forum.io/user-22129.html) | [6](https://python-forum.io/misc.php?action=whoposted&tid=24238) | 4,406 | Feb-05-2020, 11:34 PM [Last Post](https://python-forum.io/thread-24238-lastpost.html): [metulburr](https://python-forum.io/user-1.html) |
| | [updating certain values in dict. with relation to their keys](https://python-forum.io/thread-22785.html) | [malevy](https://python-forum.io/user-21173.html) | [17](https://python-forum.io/misc.php?action=whoposted&tid=22785) | 8,111 | Nov-27-2019, 02:37 PM [Last Post](https://python-forum.io/thread-22785-lastpost.html): [buran](https://python-forum.io/user-9.html) |
| | [update dict as per range of values](https://python-forum.io/thread-20878.html) | [anna](https://python-forum.io/user-6335.html) | [7](https://python-forum.io/misc.php?action=whoposted&tid=20878) | 4,604 | Sep-13-2019, 04:37 PM [Last Post](https://python-forum.io/thread-20878-lastpost.html): [anna](https://python-forum.io/user-6335.html) |
| | [match values against keys three dict](https://python-forum.io/thread-16295.html) | [anna](https://python-forum.io/user-6335.html) | [0](https://python-forum.io/misc.php?action=whoposted&tid=16295) | 2,671 | Feb-21-2019, 05:30 PM [Last Post](https://python-forum.io/thread-16295-lastpost.html): [anna](https://python-forum.io/user-6335.html) |
| | [Compare Two Values in the Same Dict](https://python-forum.io/thread-11936.html) | [malonn](https://python-forum.io/user-9221.html) | [6](https://python-forum.io/misc.php?action=whoposted&tid=11936) | 5,908 | Aug-01-2018, 03:54 PM [Last Post](https://python-forum.io/thread-11936-lastpost.html): [malonn](https://python-forum.io/user-9221.html) |
| | [sorting nested dict according to values](https://python-forum.io/thread-2672.html) | [merlem](https://python-forum.io/user-26.html) | [6](https://python-forum.io/misc.php?action=whoposted&tid=2672) | 20,271 | Apr-01-2017, 10:01 PM [Last Post](https://python-forum.io/thread-2672-lastpost.html): [snippsat](https://python-forum.io/user-7.html) |
Users browsing this thread: 1 Guest(s)
- [View a Printable Version](https://python-forum.io/printthread.php?tid=35162)
Powered By [MyBB](https://mybb.com/), © 2020 Designed by[rain](https://community.mybb.com/thread-229223.html).
[Forum Stats](https://python-forum.io/stats.php) [Contact Us](https://python-forum.io/contact.php) [Lite (Archive) Mode](https://python-forum.io/archive/index.php/thread-35162.html) [RSS Syndication](https://python-forum.io/misc.php?action=syndication)
### User Panel Messages
![]()
[Log Out](https://python-forum.io/member.php?action=logout&logoutkey=)
[My Profile Pay your profile a visit](https://python-forum.io/member.php?action=profile&uid=0)
[User Control Panel Do some changes on your profile](https://python-forum.io/usercp.php)
[My Messages View private messages unread](https://python-forum.io/private.php)
[Avatar Change avatar](https://python-forum.io/usercp.php?action=avatar)
[Signature Change signature](https://python-forum.io/usercp.php?action=editsig)
##### Announcements
[Announcement \#1](https://python-forum.io/thread-35162.html) 8/1/2020
[Announcement \#2](https://python-forum.io/thread-35162.html) 8/2/2020
[Announcement \#3](https://python-forum.io/thread-35162.html) 8/6/2020

### Login to Python Forum
Enter your details to login to your account:
Don't have an account yet? [Sign Up\!](https://python-forum.io/member.php?action=register)
[Linear Mode](https://python-forum.io/showthread.php?mode=linear&tid=35162&pid=148263#pid148263)
[Threaded Mode](https://python-forum.io/showthread.php?mode=threaded&tid=35162&pid=148263#pid148263) |
| Readable Markdown | null |
| Shard | 51 (laksa) |
| Root Hash | 14605740506344935851 |
| Unparsed URL | io,python-forum!/thread-35162.html s443 |