¡@

Home 

python Programming Glossary: pd.dataframe

Renaming columns in pandas

http://stackoverflow.com/questions/11346283/renaming-columns-in-pandas

question Just assign it to the .columns attribute df pd.DataFrame ' a' 1 2 ' b' 10 20 df.columns 'a' 'b' df a b 0 1 10 1 2 20..

pandas: apply function to DataFrame that can return multiple rows

http://stackoverflow.com/questions/13050003/pandas-apply-function-to-dataframe-that-can-return-multiple-rows

will be replicated a given number of times. For example df pd.DataFrame 'class' 'A' 'B' 'C' 'count' 1 0 2 class count 0 A 1 1 B 0 2..

Benefits of panda's multiindex?

http://stackoverflow.com/questions/13226029/benefits-of-pandas-multiindex

'one' 'one' 'one' 'two' 'two' 'two' 1 2 3 1 2 3 df pd.DataFrame np.random.randn 6 2 index pd.MultiIndex.from_tuples zip np.arrays..

How to apply a function to two columns of Pandas dataframe

http://stackoverflow.com/questions/13331698/how-to-apply-a-function-to-two-columns-of-pandas-dataframe

to do Add detail sample as below import pandas as pd df pd.DataFrame 'ID' '1' '2' '3' 'col_1' 0 2 3 'col_2' 1 4 5 mylist 'a' 'b'..

Custom sorting in pandas dataframe

http://stackoverflow.com/questions/13838405/custom-sorting-in-pandas-dataframe

pandas as pd custom_dict 'March' 0 'April' 1 'Dec' 3 df pd.DataFrame ... # with columns April March Dec probably alphabetically df.. # with columns April March Dec probably alphabetically df pd.DataFrame df columns sorted custom_dict key custom_dict.get returns a..

Understanding pandas dataframe indexing

http://stackoverflow.com/questions/14192741/understanding-pandas-dataframe-indexing

pandas as pd In 2 from numpy.random import randn In 4 df pd.DataFrame randn 6 3 columns list 'ABC' In 5 df Out 5 A B C 0 1.438161..

Custom plot linestyle in matplotlib

http://stackoverflow.com/questions/14498702/custom-plot-linestyle-in-matplotlib

as plt import pandas as pd def my_plot X Y df pd.DataFrame 'x' X 'y' Y roffset 0.1 df 'x_diff' df 'x' .diff df 'y_diff'..

How to access pandas groupby dataframe by key

http://stackoverflow.com/questions/14734533/how-to-access-pandas-groupby-dataframe-by-key

With the following groupby rand np.random.RandomState 1 df pd.DataFrame 'A' 'foo' 'bar' 3 'B' rand.randn 6 'C' rand.randint 0 20 6..

Pandas sort by group aggregate and column

http://stackoverflow.com/questions/14941366/pandas-sort-by-group-aggregate-and-column

following dataframe In 31 rand np.random.RandomState 1 df pd.DataFrame 'A' 'foo' 'bar' 'baz' 2 'B' rand.randn 6 'C' rand.rand 6 .5..

How to trouble-shoot HDFStore Exception: cannot find the correct atom type

http://stackoverflow.com/questions/15488809/how-to-trouble-shoot-hdfstore-exception-cannot-find-the-correct-atom-type

return len max x.fillna '' key lambda x len str x lengths pd.DataFrame chunk.apply f for chunk in pd.read_csv 'Train.csv' chunksize..

Using pandas DataFrame with incoming real time data

http://stackoverflow.com/questions/16740887/using-pandas-dataframe-with-incoming-real-time-data

periods 5 In 2 columns 'high' 'low' 'open' 'close' In 3 df pd.DataFrame index t columns columns In 4 df Out 4 high low open close 2013.. 10 'close' np.random.rand 10 ..... ls.append d In 11 df pd.DataFrame ls 1 3 .set_index 'time' In 12 df Out 12 close high low open..

Extracting XML into data frame with parent attribute as column title

http://stackoverflow.com/questions/16991691/extracting-xml-into-data-frame-with-parent-attribute-as-column-title

for c in p for gc in c Put them in a DataFrame In 23 pd.DataFrame elems columns 'child' 'Time' 'grandchild' Out 23 child Time..

Session generation from log file analysis with pandas

http://stackoverflow.com/questions/17547391/session-generation-from-log-file-analysis-with-pandas

a bug. Then you can use this in a groupby apply In 21 df pd.DataFrame 1.1 1.7 2.5 2.6 2.7 3.4 list 'AAABBB' .T In 22 df.columns 'time'..

How to update a subset of a MultiIndexed pandas DataFrame

http://stackoverflow.com/questions/17552997/how-to-update-a-subset-of-a-multiindexed-pandas-dataframe

number. It's the same as this but with a MultiIndex. d pd.DataFrame 'year' 2008 2008 2008 2008 2009 2009 2009 2009 'flavour' 'strawberry'..

python pandas groupby() result

http://stackoverflow.com/questions/17666075/python-pandas-groupby-result

result I have the following python pandas data frame df pd.DataFrame 'A' 1 1 1 1 2 2 2 3 3 4 4 4 'B' 5 5 6 7 5 6 6 7 7 6 7 7 'C'..

PyQt - Column of Checkboxes in a QTableView

http://stackoverflow.com/questions/17748546/pyqt-column-of-checkboxes-in-a-qtableview

self._tv def get_data_frame self if has_panda df pd.DataFrame 'Name' 'a' 'b' 'c' 'd' 'First' 2.3 5.4 3.1 7.7 'Last' 23.4..

pandas: Filling missing values within a group

http://stackoverflow.com/questions/18265930/pandas-filling-missing-values-within-a-group

by NA 's that I want to fill out to the entire trial df pd.DataFrame 'trial' 1 1 1 1 2 2 2 2 3 3 3 3 'cs_name' np.nan 'A1' np.nan..

Create a Pandas dataframe with counts of items spanning a date range

http://stackoverflow.com/questions/18775052/create-a-pandas-dataframe-with-counts-of-items-spanning-a-date-range

hence starts is positive and ends negative In 21 current pd.DataFrame 'starts' starts 'ends' ends p In 22 current Out 22 ends starts..