How To Remove Dtype And Name From Resulting Pandas Dataframe
Got the below result c(a pandas dataframe)for some operations. My question is how to remove Name and dtype from this result and extract plain values i.e [3,1,1,3....]. Is there any
Solution 1:
It looks like c
may not be a DataFrame; it might probably a list of Series objects, which is why it's printing like that. You can confirm or refute by looking at type(c)
. A better way to pull out the values, anyway, would be to use the indices as an array - you don't need to use a loop.
import pandas as pd
df = pd.DataFrame({'a':range(10), 'b':[i+5for i inrange(10)]})
res = pd.DataFrame([2,5,6,8])
c = df['b'].ix[res.values.ravel()]
print(c)
yields
27510611813Name:b,dtype:int64
In your case it would be
c = dfxn['7'].ix[res.values.ravel()]
Post a Comment for "How To Remove Dtype And Name From Resulting Pandas Dataframe"