The Python Book | |||||||
Latest All — By Topic 2019 2016 2015 2014 Topics:
angle argsort beautifulsoup binary bisect clean collinear covariance cut_paste_cli datafaking dataframe datetime day_of_week delta_time df2sql doctest exif floodfill fold format frequency gaussian geocode httpserver is join legend linalg links matrix max namedtuple null numpy oo osm packaging pandas plot point range regex repeat reverse sample_words shortcut shorties sort stemming strip_html stripaccent tools visualization zen zip Tags:
3d aggregation angle archive argsort atan beautifulsoup binary bisect class clean collinear colsum comprehension count covariance csv cut_paste_cli datafaking dataframe datetime day_of_week delta_time deltatime df2sql distance doctest dotproduct dropnull exif file floodfill fold format formula frequency function garmin gaussian geocode geojson gps groupby html httpserver insert ipython is join kfold legend linalg links magic matrix max min namedtuple none null numpy onehot oo osm outer_product packaging pandas plot point quickies range read_data regex repeat reverse sample sample_data sample_words shortcut shorties sort split sqlite stack stemming string strip_html stripaccent tools track tuple visualization zen zip zipfile |
dataframe
20190202
Turn a dataframe into an arrayeg. dataframe cn
Turn into an arrary
Sidenote: cn was pulled from city data:
dataframe
20190202
Filter a dataframe to retain rows with non-null valuesEg. you want only the data where the 'population' column has non-null values. In short
Alternative, replace the null value with something:
In detail
pandas
20161004
Turn a pandas dataframe into a dictionaryeg. create a mapping of a 3 digit code to a country name
Code:
Result:
pandas
20150302
Create an empty dataframe
Other way
dataframe
20141203
Add records to a dataframe in a for loopThe easiest way to get csv data into a dataframe is:
But how to do it if you need to massage the data a bit, or your input data is not comma separated ?
dataframe
20141202
Dataframe quickiesCount the number of different values in a column of a dataframe
Drop a column
pandas
20141019
Add two dataframesAdd the contents of two dataframes, having the same index
|