pandas_dataframe
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
pandas_dataframe [2023/06/15 16:02] – [Create a dataframe from a series of lists] raju | pandas_dataframe [2023/09/07 21:45] (current) – [lookup value] raju | ||
---|---|---|---|
Line 59: | Line 59: | ||
* https:// | * https:// | ||
+ | tags | row by row | ||
==== Create a dataframe by splitting strings ==== | ==== Create a dataframe by splitting strings ==== | ||
Given a list of strings, the idea here is to create a data frame by splitting them into multiple columns. | Given a list of strings, the idea here is to create a data frame by splitting them into multiple columns. | ||
Line 282: | Line 283: | ||
tags | uses [http:// | tags | uses [http:// | ||
+ | ==== lookup value ==== | ||
+ | To pick the first value in column ' | ||
+ | < | ||
+ | df.loc[df[' | ||
+ | </ | ||
+ | |||
+ | Example: | ||
+ | < | ||
+ | $ ipython | ||
+ | In [1]: | ||
+ | import pandas as pd | ||
+ | df = pd.DataFrame({' | ||
+ | print(df) | ||
+ | A B | ||
+ | 0 p1 1 | ||
+ | 1 p2 3 | ||
+ | 2 p3 3 | ||
+ | 3 p4 2 | ||
+ | |||
+ | In [2]: | ||
+ | df.loc[df[' | ||
+ | Out[2]: | ||
+ | 1 p2 | ||
+ | 2 p3 | ||
+ | Name: A, dtype: object | ||
+ | |||
+ | In [3]: | ||
+ | df.loc[df[' | ||
+ | Out[3]: | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | search tags | value of one column when another column equals something | ||
+ | |||
+ | Ref:- https:// | ||
===== Series related ===== | ===== Series related ===== |
pandas_dataframe.txt · Last modified: 2023/09/07 21:45 by raju