How to change the directory in python?

My script is under the directory: ‘C:\\Users\\rikesh.kayastha\\project1\\daas\\src’ My script code is : file_name_csv = "sample.csv" os.chdir(‘C:\\Users\\rikesh.kayastha\\project1\\data’) df.to_csv(file_name_csv,index=False,encoding="utf-8") This code saves the csv file in my desired directory. But this is just for local machine. How to adjust this without mentioning the local path. The base path is just project1 I want to remove the C:\\Users\\rikesh.kayastha\\… Read More How to change the directory in python?

How to use Insert in Set for Custom Data Type ? C++

class Game() { void add(set<Velocity> & v); } class Velocity() { private: // Member Variables public: // Constructors and methods } void Game::add(set<Velocity> &velocities) { Velocity v; v.setVelocity(); v.setSource(); velocities.insert(v); } As you can see I have a custom class called Game and it has a public method called Add which adds a velocity object… Read More How to use Insert in Set for Custom Data Type ? C++

Why an Int32 variable can't be assigned to an Int64 variable or vice versa in Swift?

I could not assign Int32 var/let to Int64 var/let or vice-versa in Swift. I get a compile time error when I attempt to do so. What is the reason behind this ? >Solution : If you declare a variable as Int32, the memory allocated for that variable is 4bytes and for Int64 type variable the… Read More Why an Int32 variable can't be assigned to an Int64 variable or vice versa in Swift?

remove gibberish prefix from a string

a = "aajfkdfvf_valid_name0" b = "gdhdhsdsdeeeeex_valid_name1" How do I remove the gibberish from my string before valid so that I have something like this – valid_name0 valid_name1 >Solution : If your strings always contains valid word, then you can try something like – a = "aajfkdfvf_valid_name0" b = "gdhdhsdsdeeeeex_valid_name1" for s in (a, b): print(s[s.rfind(‘valid’):])… Read More remove gibberish prefix from a string