by Suf | Mar 24, 2022 | Programming, Python, Tips
In Python 2.x, the ‘u’ in front of string values indicates that the string is a Unicode string. In Python 3, all strings are Unicode by default, and therefore you will not see the ‘u’ in front of a Unicode string. This tutorial will go through...
by Suf | Mar 23, 2022 | Programming, Python, Tips
The method apply() is a pandas method that applies a function along an axis of a DataFrame. The apply() method does not belong to the List data type. If you try to call the apply() method on a list, you will raise the AttributeError: ‘list’ object has no...
by Suf | Mar 23, 2022 | Programming, Python, Tips
If you try to remove an element from a list that does not appear in that list, you will raise the ValueError: list.remove(x) x not in list. To solve this error, you can check for list membership using the in operator, for example, if x in a_list. This tutorial will go...
by Suf | Mar 19, 2022 | Programming, Python, Tips
In Python, we can read and write to files using the with statement with the open() function. The open() function opens a file and returns a file object. The file object exposes a file-oriented API, with methods such as read() or write() to the underlying resource. If...
by Suf | Mar 19, 2022 | Programming, Python, Tips
In Python, you can use the datetime library to work with dates and times. The datetime.strftime() method converts a datetime object containing a date and time to different string formats. You cannot call strftime() on a string object because strftime() is not a method...
by Suf | Mar 18, 2022 | Programming, Python, Tips
In Python, a Pandas Series is a one-dimensional labelled array capable of holding data of any type. Pandas Series is the same as a column in an Excel spreadsheet. If you have string entries in a Series object that you want to split, you cannot use the string method...