df.interpolate(method='linear', limit_direction='forward', axis=0, inplace=True)
dff.interpolate(method='polynomial', order=3, limit=2, axis=0, limit_direction='both', inplace=True)
import pandas as pd
s = pd.Series([None, None, 'red', 'red', None, 'blue', None, None])
print(s.to_list())
print(s.bfill().tolist())
print(s.ffill().tolist())
print(s.bfill().ffill().tolist())
print(s.ffill().bfill().tolist())
print(s.interpolate(method='pad').tolist())
Output:
[None, None, 'red', 'red', None, 'blue', None, None]
['red', 'red', 'red', 'red', 'blue', 'blue', None, None]
[None, None, 'red', 'red', 'red', 'blue', 'blue', 'blue']
['red', 'red', 'red', 'red', 'blue', 'blue', 'blue', 'blue']
['red', 'red', 'red', 'red', 'red', 'blue', 'blue', 'blue']
[None, None, 'red', 'red', 'red', 'blue', 'blue', 'blue']
Code Example |
---|
Python :: how to hello world in python |
Python :: least recently used cache |
Python :: programmer tool |
:: horizontal line to the y axis in matplotlib |
Python :: python time a task |
Python :: how to set a hyperlink in python |
:: |
Python :: |
Python :: python plot n numbers from normal distribution |
:: |
:: python grab results from cursor.execute |
Python :: make django admin page text box smaller |
Python :: python inspect.getsource |
:: python system performance |
:: Python colon equals |
:: Roberta Inference TensorFlow |
Python :: re.search |
:: start ipython with any version |
Python :: |
Python :: connect to vvenv python |
:: |
Python :: centos install python 3.9 thelinuxterminal.com |
Python :: program python factorial |
Python :: change folder name python |
Python :: json.stringify equivalent in python |
Python :: |
:: |
Python :: python get bits from byte |
:: |
Python :: |