recentpopularlog in

kme : pandas   24

Installing matplotlib and pandas on Amazon EC2 | Datapolitan []
sudo yum install update
sudo yum groupinstall "Development Tools"
sudo yum install python-devel libpng-devel freetype-devel
#the last two are necessary for pip to run without failing with error 'Command "python egg_info" failed with error code 1'
sudo pip install matplotlib pandas #Finally it works!
python  pandas  webdevel  ec2  amazonami  maybesolution 
march 2017 by kme
python - How to drop a list of rows from Pandas dataframe? - Stack Overflow
Note that it may be important to use the "inplace" command when you want to do the drop in line.

df.drop(df.index[[1,3]], inplace=True)

It works with something like "df.index[df.col1 == 'value1']", too.
python  pandas  solution 
february 2017 by kme
python - Pandas dataframe to json without index - Stack Overflow
You can use orient='records'

print df.reset_index().to_json(orient='records')

{"id":0,"location":"[50, 50]"},
{"id":1,"location":"[60, 60]"},
{"id":2,"location":"[70, 70]"},
{"id":3,"location":"[80, 80]"}
pandas  json  webdevel  solution 
february 2017 by kme
indexing - Python Pandas: Get index of rows which column matches certain value - Stack Overflow
df = pd.DataFrame({'BoolCol': [True, False, False, True, True]},

In [53]: df
10 True
20 False
30 False
40 True
50 True

[5 rows x 1 columns]

In [54]: df[df['BoolCol']].index.tolist()
Out[54]: [10, 40, 50]
python  pandas  dataframe  indexing  solution 
january 2017 by kme
python - pandas select from Dataframe using startswith - Stack Overflow
...and the boolean indexing will work just fine (I prefer to use loc, but it works just the same without):

In [14]: s.loc[s.str.startswith('a', na=False)]
0 a
1 ab
dtype: object
python  pandas  dataframe  indexing  solution 
january 2017 by kme
An Introduction to Pandas | synesthesiam
Actually does a good job of explaining indexing (the '[]' syntax) and filtering. Because, fuck.

Why .ix needs .ix[idx] and not .ix(idx), I'll probably never understand.
python  pandas  tutorial  newbie  essential  reference 
january 2017 by kme
python - Pandas: Reindex Unsorts Dataframe - Stack Overflow
Instead of reindexing, just change the actual index:

dfm.index = range(1,len(dfm) + 1)
Then that wont change the order, just the index
python  pandas  index  solution 
december 2016 by kme

Copy this bookmark:

to read