I am trying to fill some missing values from one dataframe to another but couldn't able to do this. I tried different kinds of joins, also tried to use other approaches described on StackOverflow but couldn't able to do it.
Can you help me with this?
First DataFrame is related to space launches.
launches.shape
Out[10]: (5726, 11)
launches.head()
Out[11]:
tag JD launch_date launch_year type variant \
0 1967-065 2439671.38 1967-06-29 1967 Thor Burner 2 NaN
1 1967-080 2439725.70 1967-08-23 1967 Thor Burner 2 NaN
2 1967-096 2439774.83 1967-10-11 1967 Thor Burner 2 NaN
3 1968-042 2439999.69 1968-05-23 1968 Thor Burner 2 NaN
4 1968-092 2440152.69 1968-10-23 1968 Thor Burner 2 NaN
mission agency state_code category agency_type
0 Secor Type II S/N 10 US US O state
1 DAPP 3419 US US O state
2 DAPP 4417 US US O state
3 DAPP 5420 US US O state
4 DAPP 6422 US US O state
launches.isnull().sum()
Out[12]:
tag 0
JD 0
launch_date 13
launch_year 0
type 0
variant 4981
mission 21
agency 2444
state_code 0
category 0
agency_type 0
dtype: int64
You can see that the agency column has 2,444 missing values which I want to fill from the other dataframe.
The Second dataframe is related to agencies.
agencies.shape
Out[13]: (74, 19)
agencies.head()
Out[14]:
agency count ucode state_code type class tstart tstop \
0 RVSN 1528 RVSN SU O/LA D 1960 1991 Dec
1 UNKS 904 GUKOS SU O/LA D 1986 Apr 24 1991
2 NASA 469 NASA US O/LA/LV/PL/S C 1958 Oct 1 -
3 USAF 388 USAF US O/LA/S D 1947 Sep 18 -
4 AE 258 AE F O/LA B 1980 Mar 26 *
short_name name \
0 RVSN Rakentiye Voiska Strategicheskogo Naznacheniye
1 UNKS Upravleniye Nachalnika Kosmicheskikh Sredstv
2 NASA National Aeronautics and Space Administration
3 USAF United States Air Force
4 Arianespace Arianespace, Inc.
location longitude latitude error parent short_english_name \
0 Mosvka? - - - - -
1 Moskva - - - MO -
2 Washington, D.C. - - - - -
3 Washington, DC-Pentagon - - - - -
4 Paris-Evry, France - - - - Arianespace
english_name unicode_name \
0 Strategic Rocket Forces Ракетные войска стратегического назначения
1 - Управление начальника космических средств МО СССР
2 - National Aeronautics and Space Administration
3 - United States Air Force
4 - Arianespace, Inc.
agency_type
0 state
1 state
2 state
3 state
4 private
agencies.isnull().sum()
Out[15]:
agency 0
count 0
ucode 0
state_code 0
type 0
class 0
tstart 0
tstop 0
short_name 0
name 0
location 0
longitude 0
latitude 0
error 0
parent 0
short_english_name 0
english_name 0
unicode_name 0
agency_type 0
dtype: int64
I want to fill the missing agency data in the first dataframe using the second dataframe.
can you tell me how can I do this?