11-DataFrame的 reindexing

 

 

#!/usr/bin/env python
# coding: utf-8

# In[1]:


import numpy as np
import pandas as pd
from pandas import Series, DataFrame


# In[4]:


# Series

s1 = Series([1,2,3,4], index =['A','B','c','d']);


# In[5]:


s1


# In[8]:


# shift+tab  查看函数的帮助文档
s1.reindex(index = ['A','B','c','d','F'])


# In[9]:


s1.reindex(index = ['A','B','c','d','F'], fill_value=10)


# In[10]:


s2 = Series(['A','B','C'], index=[1,5,10]);


# In[11]:


s2


# In[12]:


s2.reindex(index = range(15))


# In[13]:


s2.reindex(index = range(15), method='ffill')  # full fill


# In[14]:


# df1.reindex(index = [])
# df1.redindex(cloumns= [])

# 删掉 index
# s1.drop('A')

# 删掉 df 的
# df1.drop('A', axis=0) 行
#df.drop('cl', axis=1) 列

 

posted @ 2019-06-20 14:55  aocn  阅读(98)  评论(0)    收藏  举报