Python provides a very strong module for manipulating date and time. This is specially useful in financial data since most financial data is time series data. Let’s start by import the module.
The first step would be to check the time right now:
We can also create a datetime object by passing in the year, month and day. So if we had to create an object for today’s date, we will do as follow:
today = datetime.datetime(2021, 1, 13)print(today)
Similary you can also add time. For example, we can add 3:15 pm to the date above:
event = datetime.datetime(2021, …
This article is a continue to the first one, in which we learned how to create data frames and load data into data frames from CSV and Excel files.
In today’s tutorial, we will learn how to select data from a data frame. Let’s download stocks data from Yahoo Finance by clicking the download link on the page, which lets you download the data as a CSV file. This is historic data of S&P 500 stocks. I renamed the file to stocks.csv. Let’s start by importing pandas and load data from the CSV file. …
This pandemic has completely changed our perception of the world we live in. At this point, almost all of us have been affected by it in one way of another. A lot of unfortunate souls have been lost to it and the struggle is still ongoing.
A lot of patients when they come into a hospital, may have episodes of confusion often termed as hospital delirium. Many things play a role in causing hospital delirium, like being ill, in unfamiliar surroundings, lack of quality sleep, lack of social stimulation and certain medications. Things like social interactions, family visits, and familiar objects from home being placed in their room (specially in demented patients) seem to help such episode. However, COVID-19 has made things 10 times worse for these patients. A good number of such patients is the elderly who often have vision and hearing issues. Imagine now, everyone interacting with such patients is wearing a mask, obstructing the face and lips, making lip reading impossible, as well as not letting the patient get familiar with faces, not to mention muffling the voice of the providers. All this makes the patient’s time in the hospital much harder, leading up to delirium. …
What is pandas Data Frame?
The simplest way of describing Data Frame is to think of it as a spreadsheet or table, with rows and columns. Columns are labeled by column names and row have an index column. However, Data Frame is very efficient for large amount of data. It makes applying functions to the data very efficient, both in terms of coding as well as runtime. It is probably the most commonly used pandas data object.
First of all we will import pandas as pd:
import pandas as pd
Creating a Data Frame object:
There are a few ways of creating Data Frame. Let’s start by using dictionaries. We can define our data in the form of a dictionary where each column is represented by an item in the dictionary. The key is the column name and the value contains a list of the data items. Let’s look at the following example. We have a dictionary containing our data. …
Disclaimer: Most of this code was obtained from other tutorials, I do not take credit for writing the selenium code. The purpose of this tutorial is to demonstrate Instagram automation and not to encourage posting/re-posting other people’s work. Unfortunately I am unable to find the original author of the code for Autogram, if anyone knows the author please do let me know so that I can give them credit for their awesome work.
The jupyter notebook containing all the code is available here.
What it does?
This takes a keyword as an input from the user and using it as a hashtag, retrieves public Instagram posts. It then sorts those posts based on the number of likes. The post with the most likes is then downloaded to be reposted later. It then pulls any hashtags from the caption, finds other hashtags being used with these hashtags on twitter and Instagram and use them in the caption, along with credit to the original poster of the selected post. The script then opens Instagram, logs into the user’s account and uploads the picture along with the caption. …
As a beginner in Python, lists have to be my favorite objects to work with. List comprehension reduces multiple lines of code to one line. However, if you have to work with big data, lists may not be the most efficient objects to work with. Therefore we need a more efficient alternative. Say hello to Python arrays.
Arrays behave much like lists but the content is type constrained. You have to specify the content type. Python arrays are much like arrays in C language. Consider using an array specially if your list is going to contain only numbers. When creating an array, you have to provide type code (for a list of type code, I found this page very useful). This is the key to arrays’ efficiency. For example, if you use the type code ‘b’, which in C type is signed char, and can be used for int type in python, each item is stored in a single byte, which for large sequences of numbers, saves a lot of memory. Since arrays are type constrained, Python will not let you put any item that does not fit the type specified. Therefore you are trading off the flexibility of lists but getting efficiency in return. …
New York is the greatest city in the world, is something you hear often. However, this great city has been slowly dying over the last year due to the ongoing pandemic. Having said that, a city like New York, does not fade easily. It will get back it’s chaotic yet charming vibes back soon, I have faith in that. I had written an answer to a question on Quora.com, “What’s it like to live in New York City?” and I thought this would be a good time to revisit my fond memories.
I lived in NYC for 4 years (2012–2016) and then moved out for a better career opportunity. My life in the city felt amazing. …
(Disclaimer: This is not actual money-making advice but my satirical take on all the money-making tips online.)
Making money online is easy, all you need is a laptop that works and a half decent internet connection. Which is why all the people who spend so much time on the internet are so rich. Let us deliberately ignore the fact that only very few of the thousands of people online make enough money to qualify to be termed as “significant”, without having to move to a cheaper country. Not to deny that persistence is the key and this will require multiple streams, but I will make is all sound so easy to keep you hooked and maybe click on my referral links so that I can make more money from my article about how to make money. …
I do not think of myself as someone who knows about money. After reading some of the articles on here, I have realized that I never really “planned” my finances and have lived just day to day. I thought about it a lot and reached the conclusion that there are broadly two types of people when it comes to spending money.
The Careful Investor:
My ex-roommate, who happens to be one of my closest friends, an engineer, is very good with money. In discussions with him, phrases like “maximizing potential” and “getting my money’s worth” are commonly heard. He is 34, makes 6 figures, worth 600k to 1 million (my guesstimate). However, any decision that involves money, means weeks of research, tons of discussions and once that money is spent, a period of panic with a hint of regret about spending that money. He does some charity work but very calculated. He will also gift people, and usually the value of the gift is calculated based on what sort of gift they have given him in the past. In the end, he has done very well, his net worth has increased, but at the cost of countless panic attacks and sleepless nights. He is rich sure, he is happy too, but is his day to day life easier? …
While working on a project recently, I had to work with time series data spread over a year. I wanted to add columns for whether a specific date was a holiday, as well as wanted to count number of days from the previous holiday and days to the next holiday. As someone relatively new to Python, it was a bit of a challenge. However, after some research online, I found out that it is rather simple, and decided to share. Here are the goals of this article: