I'm working with an Dataframe that have latitude and longitude columns. I found some problems with part of this dataframe. Filtering the columns = latitude and longitude with problem i found:
The Orginal Dataframe filtered by latitude and longitude: df17
input:
df17[['latitude','longitude']].info()
output:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 204395 entries, 431458 to 635852
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 latitude 204395 non-null float64
1 longitude 204395 non-null float64
dtypes: float64(2)
memory usage: 4.7 MB
I've been filtered the values latitude and longitude that doesn't make any sense for me...
input:
df17.loc[((df17['longitude']>-35)|(df17['longitude']<-71)|(df17['latitude']>5)|(df17['latitude']<-34)),['latitude','longitude']]
output:
latitude longitude
431460 -23.369520 309.935131
431461 -23.369520 309.935131
431609 -8.057838 -34.882897
431610 -8.057838 -34.882897
431620 -12.274928 -415.558205
... ... ...
635465 -7.179325 -34.900260
635527 -7.915741 -34.898170
635528 -7.915741 -34.898170
635583 -7.128831 -34.952970
635584 -7.128831 -34.952970
4935 rows × 2 columns
So I've been working on those 4935 rows and fixed that, creating a new DataFrame = df_latilon
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4935 entries, 0 to 4934
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Latitude 4935 non-null float64
1 Longitude 4935 non-null float64
dtypes: float64(2)
memory usage: 77.2 KB
Now I would like to replace the rows in main Data Frame df17 with those fixed (from df_latitlon), but I'm not sure how to replace only filtered rows in df_17 main data frame.
I've been tried in that way:
Input:
df17.loc[((df17['longitude']>-35)|(df17['longitude']<-71)|(df17['latitude']>5)|(df17['latitude']<-34)),['latitude','longitude']]=df_latilon[['latitude','longitude']]
Output:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 204395 entries, 431458 to 635852
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 latitude 199460 non-null float64
1 longitude 199460 non-null float64
dtypes: float64(2)
memory usage: 4.7 MB
But it not worked, and looks that those 4935 rows were droped from Data Frame ..
Can someone help me with that ?
Thanks so much....