I'm looking for a way in python to achieve similar functionality to the unix cut
utility. I know I can make a system call and process my data that way but I'd like to make it a bit more "pythonic" and do it with python libraries.
Example text
abcde:12345
I'd like to delimit on :
and keep the second field:
cut -d':' -f2
to produce:
12345
thoughts?
cut() method in Python. Pandas cut() function is used to separate the array elements into different bins . The cut function is mainly used to perform statistical analysis on scalar data.
To delete rows and columns from DataFrames, Pandas uses the “drop” function. To delete a column, or multiple columns, use the name of the column(s), and specify the “axis” as 1. Alternatively, as in the example below, the 'columns' parameter has been added in Pandas which cuts out the need for 'axis'.
Use pd. cut() for binning data based on the range of possible values. Use pd. qcut() for binning data based on the actual distribution of values.
You can do:
string.split(":")[1]
where string is your text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With