Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,939 questions

51,876 answers

573 users

How to create NaN values in Pandas DataFrame in Python

1 Answer

0 votes
import pandas as pd
import numpy as np
 
data = {'A': [1,2,3,4,np.nan,5,np.nan,np.nan,6,7,8,np.nan]}

df = pd.DataFrame(data, columns=['A'])
 
print(df)
 
 
 
  
  
'''
run:
  
     A
0   1.0
1   2.0
2   3.0
3   4.0
4   NaN
5   5.0
6   NaN
7   NaN
8   6.0
9   7.0
10  8.0
11  NaN
 
'''

 



answered Jan 12, 2021 by avibootz
edited Jan 12, 2021 by avibootz

Related questions

...