473,500 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropna inplace not working. Can anyone help.

308 Contributor
dropna inplace not working. Can anyone help.
Aug 25 '20 #1
5 7286
hussainmujtaba
13 New Member
Usually when it does not wrok, it usually means that you don't have nan values in data frame .Instead you have empty strings.Just remove them.Check out these data preprocessing steps to know more.
Aug 31 '20 #2
madankarmukta
308 Contributor
I want to set mean value for all empty string instead of removing them.

here is the thing.
df = df.replace(r'^\s*$', np.NaN, regex=True)

Thanks
Thanks
Sep 4 '20 #3
SioSio
272 Contributor
Is this the code you are looking for?
Expand|Select|Wrap|Line Numbers
  1. import pandas as pd
  2. import numpy as np
  3. s = pd.Series([2.0, np.nan, 0.5, 1.5, np.nan, 1.0])
  4. print(s)
  5. m = s.mean()
  6. print(m)
  7. s.fillna(m,inplace=True)
  8. print(s)
Sep 7 '20 #4
madankarmukta
308 Contributor
I hardly think mean is suitable for series you have.

Can you please help to understand what you tried to achieve here for the series.

Thanks.
Sep 10 '20 #5
SioSio
272 Contributor
What you want to do is find whitespace in the panda's dataframe, replace those values ​​with NaN, and even remove NaN?
Expand|Select|Wrap|Line Numbers
  1. df.replace(r'^\s*$', np.nan, regex=True, inplace=True)
  2. print(df)
  3. df.dropna(inplace=True)
  4. print(df)
Sep 10 '20 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2048
by: J. Nielsen | last post by:
I'm not a programmer and I don't have the time and energy to start learning right now So I need some help. Let's say I have made an HTML Table (consisting of three columns and six rows). In each...
16
3154
by: Andie | last post by:
Hello All, I have this sql statement thats works in MSSQL when I call a function function showNewProd(dispNum) 'Declare some variables dim mySQL, rsTemp, tempStr, count 'Read Database
12
1609
by: ThunderMusic | last post by:
hi, I have two classes in C#, one is the base, the other inherits from the base class... both are generics... Here is the definition of the second class : public class...
1
4225
by: Aluear | last post by:
WE are working in a Anti-virus tool which is developed in .Net. While we try to automate the Tool exe in "Selenium IDE", we caught with the following error message. "CLR: 8007000b The program...
0
1494
by: Pratik Patel | last post by:
Hi,OpenPNE is open source japanese social network. AND it's also have facility to transfer language in english in next version.but i see two site which is translated in english. can anyone help to...
5
2092
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this...
3
1665
by: Cara83 | last post by:
Hi everyone, I am only new to this Perl programming world and I am having problems with the script I am writing. The program is supposed to search a number of specified directories for files...
6
1599
by: backups2007 | last post by:
Here's my code. For some reason, it's not working. Please help... Thank you. <? $so_no=$_POST; //customer type $ctype=$_POST; //customer info $cust_id=$_POST; $walkin_id=$_POST;
1
1824
by: hitlerassdome | last post by:
why this code is not working please help. thanks my $count = 0; $count = $dbh->do("INSERT INTO ques...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7018
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7235
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6909
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5491
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4614
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.