You can map dict values inside fillna
df.B = df.B.fillna(df.A.map(dict))
print(df)
A B
0 a 2
1 b 5
2 c 4
More Related Contents:
- How to split data into 3 sets (train, validation and test)?
- Pandas bar plot changes date format
- Show DataFrame as table in iPython Notebook
- Export from pandas to_excel without row names (index)?
- How to create a table with clickable hyperlink in pandas & Jupyter Notebook
- Pandas – Find and index rows that match row sequence pattern
- Trouble installing Pandas on new MacBook Air M1
- (pandas) Create new column based on first element in groupby object
- Pandas, group by count and add count to original dataframe?
- using time zone in pandas to_datetime
- Python/Pandas: counting the number of missing/NaN in each row
- Kalman filter with varying timesteps
- pandas dataframe group and sort by weekday
- Merge two data frames based on common column values in Pandas
- Why does it take ages to install Pandas on Alpine Linux
- Pandas: convert date in month to the 1st day of next month
- Splitting multiple columns into rows in pandas dataframe
- Getting Colorbar instance of scatter plot in pandas/matplotlib
- All possible combinations of columns in dataframe -pandas/python
- Why are Pandas and GeoPandas able to read a database table using a DBAPI (psycopg2) connection but have to rely on SQLAlchemy to write one?
- Pandas & AWS Lambda
- Scrape tables into dataframe with BeautifulSoup
- How to remove illegal characters so a dataframe can write to Excel
- Plot pandas dataframe containing NaNs
- Turn pandas dataframe into a file-like object in memory?
- How can I left justify text in a pandas DataFrame column in an IPython notebook
- concise way of flattening multiindex columns
- use Featureunion in scikit-learn to combine two pandas columns for tfidf
- Convert dataframe with start and end date to daily data
- Grouped seaborn.barplot from a wide pandas.DataFrame